2

Java + Struts2 Scenario: A web page with search having from and to date which uses Jquery datepicker(mm/dd/yy). When using this web page from Desktop/Laptop the date conversion from date field to java Date object is working fine. Means when posting a date "01/12/2016" in java Date object i get "12th january 2016" but when using it from mobile device date object in Java will show "1st December 2016".

Is there any configuration parameter which i need to set in struts ?

VirajC
  • 68
  • 7
  • 2
    This screams localisation. But you need to add some of the code, that we can help yo out. – jHilscher Jan 20 '16 at 06:19
  • See [Is it possible to configure unified format of date format for whole struts webapp](http://stackoverflow.com/a/23084580/573032) – Roman C Jan 20 '16 at 08:51
  • Yes it was problem with localisation. Struts convert String to Date based on device local. Now I have overridden struts type conversion for Date and it works perfect for my scenario. https://struts.apache.org/docs/type-conversion.html – VirajC Jan 22 '16 at 03:45

1 Answers1

0

Read how Struts2 handles date conversion.

You can specify the locale server side and the dateFormat client side, as described here.

You should also consider using the native HTML5 datepicker, very important for mobile browsing.

If using RFC3339 dates, however, remember to create a simple converter, or wait for Struts 2.3.25.

Community
  • 1
  • 1
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243