Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Jesper W
Non-US Date and Time formatting in the ui:input-date & time tags
July 22, 2008 7:07 AM
Answer

Jesper W

Rank: Expert

Posts: 315

Join Date: March 25, 2007

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
Jorge Ferrer
RE: Non-US Date and Time formatting in the ui:input-date & ti
July 22, 2008 9:04 AM
Answer

Jorge Ferrer

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2757

Join Date: August 31, 2006

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.
Jesper W
RE: Non-US Date and Time formatting in the ui:input-date & ti
July 23, 2008 2:00 AM
Answer

Jesper W

Rank: Expert

Posts: 315

Join Date: March 25, 2007

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.
Jorge Ferrer
Re: [Liferay Forums][Liferay Core Developers] RE: Non-US Date and Time form
July 23, 2008 2:08 AM
Answer

Jorge Ferrer

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2757

Join Date: August 31, 2006

Recent Posts

Sounds good to me
Jesper W
RE: Non-US Date and
July 23, 2008 5:10 AM
Answer

Jesper W

Rank: Expert

Posts: 315

Join Date: March 25, 2007

Recent Posts

Oki, patch contributed in LEP-6827
Jakub Liska
RE: Non-US Date and
November 14, 2010 3:56 PM
Answer

Jakub Liska

Rank: Regular Member

Posts: 187

Join Date: March 25, 2010

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