Non-US Date and Time formatting in the ui:input-date & time tags

thumbnail
28386, modified 17 Years ago. Expert Posts: 310 Join Date: 3/25/07 Recent Posts
I'd like to make the <liferay-ui:input_xxx> tags for date and time adopt to European standards:

- 24h time format instead of AM/PM
- Y-M-D ordering of the date selectors.

AFAICS there is no info in Locale, GregorianCalendar or SimpleDateFormatter about what format is the standard in different locales.
The only way I can think of right now is to add a property to select what format should be used.

Anyone with better ideas?

/jesper
thumbnail
10437, modified 17 Years ago. Liferay Legend Posts: 2871 Join Date: 8/31/06 Recent Posts
Hi Jesper,

Ideally it should use the locale of the current user. Actually it's already using that within the taglib/ui/input_time/page.jsp to format the individual numbers.

The hard part could be adapting all the actions (or classes reading those params in general) so that they can read the fields in the appropriate locale.
thumbnail
28386, modified 17 Years ago. Expert Posts: 310 Join Date: 3/25/07 Recent Posts
So I found that by extracting the formatting pattern from getDateInstance() and getTimeInstance() it is possible to determine if the default time format is AM/PM or 24h, and if the default date order is MDY or YMD.

I can easily get input-field and input-time to adhere to this without any need to change any of the Action classes that process the input, since the Action classes just add 12h if the hour value is PM.

It's quite easy to change the display order of input-date too, but since the display order is determined by the order the tags appear in the HTML I would need to duplicate the year, month and day <select> tags in input-date/page.jsp.

Would this be considered OK?

I don't like code duplication, but the only alternative I can think of is to extract month, day and year <select>'s into 3 separate .jspf's, and then include them in different order depending on the Locales preferred order.
thumbnail
10437, modified 17 Years ago. Liferay Legend Posts: 2871 Join Date: 8/31/06 Recent Posts
Sounds good to me
thumbnail
28386, modified 17 Years ago. Expert Posts: 310 Join Date: 3/25/07 Recent Posts
Oki, patch contributed in LEP-6827
thumbnail
4761731, modified 15 Years ago. Regular Member Posts: 187 Join Date: 3/25/10 Recent Posts
Hi Jasper,

I'm not sure how do you mean this
So I found that by extracting the formatting pattern from getDateInstance() and getTimeInstance() it is possible to determine if the default time format is AM/PM or 24h, and if the default date order is MDY or YMD.

When these liferay-ui:input-date/time are used, request is populated with all the particular time/date values (Integers) that you can get separately .... I don't see any DateFormat I could call these methods on to find out whether the request came from somebody from US or EU