我有一个
i)称为gmtoffset的整数变量(这是从基准时间加/减的小时/分钟数),以及
ii) map对象(称为result),它包含GMT中的时间戳。我需要迭代到map对象中,并根据gmtoffset变量中的小时数加/减来更改map对象中的时间戳。
例如,int gmtoffset = 0230 , changedTimestamp = 2013-09-11 01:11:00.1
我的最后一个changedTimestamp变量应该是2013-09-11 10:41:00.1
请求帮助。
发布于 2013-10-22 09:55:26
您可以使用Java Calendar和SimpleDateFormat来完成这项工作。类似于以下内容:
Date date = <convert your changedTimesetamp to a date, see SimpleDateFormat>
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
cal.setTime(date);
cal.add(Calendar.MINUTE, gmtoffset);注意:假设gmtoffset以分钟为单位表示...所以2小时30分钟就是150分钟。
https://stackoverflow.com/questions/19507286
复制相似问题