Java Date SimpleDateFormat Locale

        Date date = new Date();
        System.out.println(date);
        System.out.println(new SimpleDateFormat().format(date));
        System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS").format(date));
        System.out.println(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").format(date));
        System.out.println(new SimpleDateFormat("EEEEEE, d MMMMM yyyy HH:mm:ss Z", Locale.US).format(date));
        System.out.println(new SimpleDateFormat("EEEEEE, d MMMMM yyyy HH:mm:ss Z", new Locale("pl", "PL")).format(date));

Result:

Fri Apr 17 12:22:53 CEST 2015
4/17/15 12:22 PM
2015-04-17 12:22:53,359
2015-04-17T12:22:53.359+02:00
Friday, 17 April 2015 12:22:53 +0200
piątek, 17 kwiecień 2015 12:22:53 +0200
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s