Web application suitable for different locale

Version 6.7 has introduced formatting option where for example, we can format date appropriate to specific locale. This is a good enhancement and I have started using it (in RC6.7).

However, I am wondering, what will happen when my application will be used by users from across the world where even we have option to use different language. For example, the Date format in Canada is mm/dd/yyyy whereas it is mm/dd/yyyy in USA. Number format in Canada is #,###,##0.00 where as it is #.###,00 in Germany and ##,##,###.00 in Bangladesh and India.

Is it possible we can handle this with defining the formats in different locale in CUBA-PLATFORM which standard feature in Java?

Hi Mortoza,

First of all, the datatypes mechanism with locale-dependent format strings is still the main method of formatting values.

The @NumberFormat annotation is a shortcut to simplify ad-hoc formatting. It will use decimalSeparator and groupingSeparator from format strings (if you don’t specify them in the annotation), but if you need a different pattern you have to use datatypes.

Date and time values can be handled only by datatypes, @NumberFormat is only for numbers.

Hi Konstantin,
If I understood correctly, when I use datatypes to handle different formatting it will work only for the format I use in the datatype which is locked with specific format. However, my requirement is, the same instance of web application to be used by say, US and Canadian users where date format is dd/mm/yyyy for Canadian users and mm/dd/yyyy format for US users. How can we achieve it? Thanks for shedding some lights.

Mortoza

Format strings (date and number patterns, decimal and grouping separators, true/false strings) are not hardcoded in the datatypes. Instead, they are specified in message packs, which are different for different locales. You can even specify the format strings in Studio: edit Project Properties, click the button in the Available locales field, then click Show data format strings. So you can have en_US locale with mm/dd/yyyy date pattern and en_CA locale with dd/mm/yyyy pattern.

Thank you so much. Sorry for the confusion.