开发者

subtract hours as string in Calendar Instance in java

I have the hours format in string as 24hours format..."YYYYmmddHHmmss"(year,month,date,hours,mins,seconds) suppose if i pass the hours as 2hours means,it should subtract 2 hours from the currentDateTime like "20110217182000";...("20110217182000" - 2hours) what is the problem na, the current hours is like as "201102*17000000*",after subtracting t开发者_JAVA百科his hour as should come with yesterday date...like the answer "201102*16220000*" in string format.......plz any one help me?????????? Thanks


If you store the date in a Calendar object (named, say, cal), you can use

cal.add(Calendar.HOUR_OF_DAY, -numberOfHours);

where numberOfHours is the amount you want to subtract.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜