I am trying to get an abbreviated time zone, ex. PST, EDT etc. I managed to get an offset but was unable to get an abbreviated timezone based on the offset.
Can anyone help?
For example, when
tz = America/Phoenix and time =1450759239340
DateTimeFormat.forPattern("zzz").withZone(tz).print(time);
I get -07:00 as a result.
Can I get an abbreviated time zone with these available code?
Thanks in advance.
Here is how , you can get different date format using SimpleDateFormat and Calendar class.
One of these is to get PDT, IST kind of output using
z
in small case.if you want elaborated names use
zzzz
.I would recommend choosing you desired date format from below:
You may use SimpleDateFormat to get proper formatted string from date or vice-versa.
For example
See my blog on same.
Hope it helps!