Planned maintenance is scheduled for the week of June 15th - the exact date and time will be announced soon.
See More Details
Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Non-US Date and Time formatting in the ui:input-date & time tags
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
- 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
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.
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.
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.
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.
Sounds good to me
Oki, patch contributed in LEP-6827
Hi Jasper,
I'm not sure how do you mean this
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
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
Community
Company
Feedback