开发者

Will my database timestamp fields get automatically converted to GUI user's timezone

I have a bunch of timestamp fields in my 开发者_如何学Pythonjava model bean which is sent the view. If a user in another country or timezone tries to view these fields, will they be shown in the user's timezone. If not, could you provide a code snippet to do this conversion to the users timezone.

[Update] Adeels reply below will work, and this following link shows how to set it when getting the bean from database itself.


Get the user's time zone, and use Calendar.setTimeZone() to set the time zone and retrieve the Timestamp according to the user's time zone. You can instantiate Calendar using that TimeZone, i.e.

Calendar cal = GregorianCalendar.getInstance(userTimeZone);

Or you can set it afterwards like,

Calendar cal = Calendar.getInstance();
cal.setTimeZone(userTimeZone);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜