为什么Date不是在GWT 2.6中进行序列化? [英] Why Date is not Serializing in GWT 2.6?
问题描述
GWT 2.6没有正确序列化Java日期。当我输入日期17.10.1983它显示16.10.1983,如果我输入16.10.1983它显示15.10.1983。我该如何解决它?
它可能是locale / timezone问题。您可以通过将值传递为long(时间以毫秒)或字符串(日期为字符串)来解决此问题。只需将日期对象形成回服务器端。
我的另一篇文章可能会帮助你在gwt.xml中设置语言环境不起作用
如何在服务器端根据客户端语言环境重新构建日期对象?
示例代码:
语言环境locale = httpRequest.getLocale(); //获取客户端浏览器语言环境
SimpleDateFormat formatter =(SimpleDateFormat)DateFormat.getDateTimeInstance(
DateFormat.SHORT,DateFormat.MEDIUM,locale);
GWT 2.6 is not serializing Java Date properly.When i Enter the Date 17.10.1983 it shows 16.10.1983 and if I enter 16.10.1983 it shows 15.10.1983.How can i solve it?
It may be the locale/timezone issue. You can solve it by passing value as long (time in milliseconds) or string (date as string). Just form the date object back at the server side.
My another post might help you Setting locales in gwt.xml do not work
How you can form the the date object back at server side based on client locale?
Sample code:
Locale locale = httpRequest.getLocale(); // Get the client browser locale
SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateTimeInstance(
DateFormat.SHORT, DateFormat.MEDIUM, locale);
这篇关于为什么Date不是在GWT 2.6中进行序列化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!