aspose file tools*
The moose likes Java in General and the fly likes SimpleDateFormat question 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 » Java in General
Bookmark "SimpleDateFormat question" Watch "SimpleDateFormat question" New topic
Author

SimpleDateFormat question

Lisa Drebendorf
Greenhorn

Joined: Aug 21, 2002
Posts: 2
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

Joined: Mar 09, 2000
Posts: 34
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

Joined: Aug 21, 2002
Posts: 2
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

Joined: Jul 11, 2001
Posts: 14112
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 ]

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SimpleDateFormat question