• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SimpleDateFormat question

 
Lisa Drebendorf
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a question concerning SimpleDateFormat.
When I do:

I get:
Wed Aug 21 13:34:00 CEST 2002
Mi, 21 Aug 2002, 13:34:00
Mi is 'Mittwoch' which is German for 'Wednesday'. I also suppose that the months are translated to German, as I am using the German time-settings.
How can I get the date in the format
Wed, 21 Aug 2002, 13:34:00
In short: I need to format Date(), but keep the English names.
How can I do this?
Thanks in advance
Lisa
Greetings from Germany !
 
Veena Rani
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can create a Locale class object with language as English and use this Locale object in the Constructor of SimpleDateFormat class
e.g
Locale l= new Locale("en","DE");
SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy, HH:mm:ss",l);
You can specify the required language and country code in the Locale constructor
Veena
 
Lisa Drebendorf
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Veena,
thank you for your help, this did solve my problem.
I guess SimpleDateFormat gets the systems country and language settings and formats the given date using these settings. Am I right?
So, when I'm using e.g. English settings for country and language on my system I will get the English day-names without using the Locale object explicitly?
Again, thanks for your help!
Lisa
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lisa Drebendorf:
I guess SimpleDateFormat gets the systems country and language settings and formats the given date using these settings. Am I right?

Yes. See java.util.Locale.getDefault()
[ August 22, 2002: Message edited by: Ilja Preuss ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic