Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

date i18n

 
Lisa D'Aniello
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Locale is your UK machine configured to use? It may well be en_US too.
 
Lisa D'Aniello
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure. How do i find out?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic