现在的位置: 首页 > 综合 > 正文

Date&Time in java codes&XML

2014年02月06日 ⁄ 综合 ⁄ 共 572字 ⁄ 字号 评论关闭

 Date&Time in java codes&XML

 Problem Description
The path of the Time is,
 
Java.util.Date --> XML: datetime --> Java.util.Calendar.getTime()
 
If we have not done any additional change for the Time functions, the result in the end will be many hours away from the actual time.
 
One possible Solution
java.util.Date nowdate=new java.util.Date();    
nowdate.setTime(nowdate.getTime()
-nowdate.getTimezoneOffset()*60*1000);

ps:  getTimezoneOffset():  unit is minute
         setTime() and getTime(): unit is millisecond

Calendar CaseStartDate = srs.getCaseDateInfo().getCaseStartDate();
nowdate
=CaseStarDate.getTime();// Get day and time

抱歉!评论已关闭.