开发者

Java. Creating a date according to user timezone in web-application

开发者 https://www.devze.com 2023-04-08 08:29 出处:网络
I have a Java web-application. In some places there is showing of dates. I want to display the date according to user timezone. How do I create a date for the show if I know the timezone the user?

I have a Java web-application. In some places there is showing of dates. I want to display the date according to user timezone. How do I create a date for the show if I know the timezone the user? I use the class Date. Any help would be greatly appr开发者_如何学JAVAeciated.


There is no standard way to do this. On client side, you may capture time using Java script and send that information to the server. On server side, you can covert the time to Coordinated Universal Time.


Use GregorianCalendar rather than Date when you have any requirements besides basic display. You can create one for the current time by time-zone using new GregorianCalendar(TimeZone).

0

精彩评论

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

关注公众号