Why Date is not Serializing in GWT 2.6?

前提是你 提交于 2020-01-16 19:16:33

问题


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?


回答1:


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);


来源:https://stackoverflow.com/questions/23824835/why-date-is-not-serializing-in-gwt-2-6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!