Monday 15 July 2013

java - DateFormat discrepancy -


We are trying to format dates according to the browser locale. However, when we pass "en_GB" to start the "code"> locale context and pass it on "codeFormat" , in contrast to using the "pure" code, Receiving different output request to local context.

In the former case, output is: 6/20/13, while later (right) output is: 20/06/13.

What could be the reason for this discrepancy?

instead of:

  locale locale = new locale ("en_GB ");   

You should use:

  locale locale = new locale ("N", "GB");   

To specify the language and country, you use different logic. Similarly if you want to include a type, you can use constructor with three parameters.

No comments:

Post a Comment