Fórum

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

thumbnail
Jesper W, modificado 15 Anos atrás.

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

Expert Postagens: 310 Data de Entrada: 25/03/07 Postagens Recentes
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
Jorge Ferrer, modificado 15 Anos atrás.

RE: Non-US Date and Time formatting in the ui:input-date & ti

Liferay Legend Postagens: 2871 Data de Entrada: 31/08/06 Postagens Recentes
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
Jesper W, modificado 15 Anos atrás.

RE: Non-US Date and Time formatting in the ui:input-date & ti

Expert Postagens: 310 Data de Entrada: 25/03/07 Postagens Recentes
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
Jorge Ferrer, modificado 15 Anos atrás.

Re: [Liferay Forums][Liferay Core Developers] RE: Non-US Date and Time form

Liferay Legend Postagens: 2871 Data de Entrada: 31/08/06 Postagens Recentes
Sounds good to me
thumbnail
Jesper W, modificado 15 Anos atrás.

RE: Non-US Date and

Expert Postagens: 310 Data de Entrada: 25/03/07 Postagens Recentes
Oki, patch contributed in LEP-6827
thumbnail
Jakub Liska, modificado 13 Anos atrás.

RE: Non-US Date and

Regular Member Postagens: 187 Data de Entrada: 25/03/10 Postagens Recentes
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