Prevent java from localizing SimpleDateFormat output

Basically I want to format a Date object using a certain pattern and the output should be in English. How can I prevent java from translating the output to 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

      

+2


source to share


1 answer


SimpleDateFormat

is always localized, it doesn't make any sense.

However, you can tell Locale to use when creating it, eg.



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

      

+4


source







All Articles