stefita
stefita

Reputation: 1793

Prevent java from localizing SimpleDateFormat output

Basicaly I want to format a Date object using a specific pattern and the output should be in English. How can I prevent java from translating the output in the system language?

String date = new SimpleDateFormat("EEE MMM dd kk:mm:ss yyyy").format(myDate);
// output is in German:
// Mi Aug 26 16:35:55 2009

Upvotes: 3

Views: 1078

Answers (1)

skaffman
skaffman

Reputation: 403481

SimpleDateFormat is always localized, it makes no sense otherwise.

You can, however, specify the Locale to use when you build it, e.g.

SimpleDateFormat format = new SimpleDateFormat(
   "EEE MMM dd kk:mm:ss yyyy", 
   Locale.ENGLISH
);

Upvotes: 6

Related Questions