In JSF - Getting the Client's Locale (To Display time in browser's timezone)

后端 未结 6 2117
失恋的感觉
失恋的感觉 2020-12-28 10:03

I\'m writing a webapp in JSF 2.0 that displays Timestamps as part of the information to the user. I would like the user to see the timestamps localized to their location (br

6条回答
  •  猫巷女王i
    2020-12-28 10:39

    If all you need is to display time stamps with the users local time you dont need the Locale object (you need to add the users hours offset to GMT + 0 time), Y You need to send the value of timezone.offset() (from the example in the link) to the server (you can do it by using servlet post with parameter)

    and then add this offset to the date object created on your server (set your locale on the server to be GMT + 00)

    that way you will create time stamps with the correct time of the user that is logged into your web app

    (that's what I did myself...)

提交回复
热议问题