wood burning stoves*
The moose likes Beginning Java and the fly likes date i18n Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "date i18n" Watch "date i18n" New topic
Author

date i18n

Lisa D'Aniello
Ranch Hand

Joined: Sep 25, 2003
Posts: 42
Hi there,

i have the following code, that works great in the US. I was hoping that it would also work great in the UK, but...
It returns US format in the UK. Any ideas as to why?

Thanks for any help you can offer,
Lisa
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What Locale is your UK machine configured to use? It may well be en_US too.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Lisa D'Aniello
Ranch Hand

Joined: Sep 25, 2003
Posts: 42
I'm not sure. How do i find out?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Just examine the result of Locale.getDefault(). That will tell you. Though the DateFormat stuff you are using usses the default anyway, so it does look liek your JVM is configuered for an en_US Locale.
Lisa D'Aniello
Ranch Hand

Joined: Sep 25, 2003
Posts: 42
Thank you so very much! For a minute there i was afraid that I had the entire concept of date formats wrong!
Barry Higgins
Ranch Hand

Joined: Jun 05, 2003
Posts: 89
I've run your code from Ireland and was surprised to find my default SHORT was set to M/d/yy.
After looking this up it appears the Locale has to be explicitly set. I thought the JVM might have some way of picking this up at start-up.

Anyway you can avoid all of this unpleasantness by specifying the Locale when you get your DataInstance.

Lisa D'Aniello
Ranch Hand

Joined: Sep 25, 2003
Posts: 42
Hi Barry,
Thanks for the code bit - i really appreciate it. I should not have to code for each locale of visitor I expect to see, since this should be as simple as getting the default date. I suppose that what I need to know is how to configure the JVM properly.

I appreciate everyones help - and if i ever figure out how to get it going, i'll post it back here for everyone else to use.

Originally posted by Barry Higgins:
I've run your code from Ireland and was surprised to find my default SHORT was set to M/d/yy.
After looking this up it appears the Locale has to be explicitly set. I thought the JVM might have some way of picking this up at start-up.

Anyway you can avoid all of this unpleasantness by specifying the Locale when you get your DataInstance.

 
jQuery in Action, 2nd edition
 
subject: date i18n