• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Change date for other languages ?

 
Ranch Hand
Posts: 119
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a little doubt, when I execute this simple code, he return for me the String in English, in the case just the Month, but I wanted in portuguese.

Caso someone can help me, thanks a lot.


 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sure that SimpleDateFormat must have a setLocale method...
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think it has. The nearest I can find is that if you use System.getProperties you get user.country which corresponds to UK in my case. You can try changing that; of course if I change that to "FR" my computer will spend the next week trying to feed me snails and frogs and saying "pas manger le rosbif" (Don't eat roast beef)

So you will have to remember to change it back afterwards.

There are bound to be other similar properties elsewhere. Somebody else will doubtless know something sensible.
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On another recent thread I noticed the getDateInstance method takes a Locale as a parameter, so that sounds more promising.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Indeed SimpleDateFormat does not have a setLocale method, but it does have a constructor to which you can pass a Locale object:


You can also change the default locale, but not by changing a system property as Campbell suggests. Class Locale has a static setDefault method:

This will not be a persistent setting; it will remain in effect only for the JVM that is currently running your program.
 
Edson Cezar
Ranch Hand
Posts: 119
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:Indeed SimpleDateFormat does not have a setLocale method, but it does have a constructor to which you can pass a Locale object:


You can also change the default locale, but not by changing a system property as Campbell suggests. Class Locale has a static setDefault method:

This will not be a persistent setting; it will remain in effect only for the JVM that is currently running your program.



First, thank for all, I did this example here:



Your output is this :

Sabado, 3 de Setembro de 2011

But I want this output :

3 de Setembro de 2011

I thank anyone who can help me

 
Edson Cezar
Ranch Hand
Posts: 119
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all for help me, I did this code, I know this code isn't the best way, but I tried



The output of code is :

Month : 3 de Setembro de 2011 (I needed exactly this)

 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can't you put something like "dd de MMMM de yyyy" into the df constructor? Or DateFormat.LONG instead of FULL?
 
Edson Cezar
Ranch Hand
Posts: 119
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Can't you put something like "dd de MMMM de yyyy" into the df constructor? Or DateFormat.LONG instead of FULL?



Thank you,

I think this is the more simple that I can do :



Thank for all
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic