Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SimpleDateFormat and TimeZone format

I am trying to make the SimpleDateFormat class to do what I need without success.

Here is the date format I need:

Fri 29 May 2015 10:22:30 GMT-0400 (Eastern Daylight Time)

Here is the closest format definition I was able to come with:

SimpleDateFormat("EEE dd MM yyyy HH:mm:ss Z (zzzz)", Locale.ENGLISH)

This will output:

Fri 29 May 2015 10:22:30 -0400 (Eastern Daylight Time)

Is there a formatting that can do what I need or do I have no other choice than manipulating the String to insert the missing GMT tag?

like image 336
Achille Avatar asked Apr 27 '26 13:04

Achille


1 Answers

You can add the literal GMT surrounded by quotes:

new SimpleDateFormat("EEE dd MM yyyy HH:mm:ss 'GMT'Z (zzzz)", Locale.ENGLISH);
like image 192
M A Avatar answered Apr 30 '26 04:04

M A



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!