The main problem: "GMT" TimeZone returns things at its discretion. "etc / GMT" returns with an additional "+0: 00", which is undesirable. "etc / Greenwich" seems to confuse people that they relate to a specific location, this is undesirable.
So why is it bad practice to use "GMT"?
Original publication
In Java Doc
Note that abbreviation support is for JDK 1.1.x compatibility only and full names should be used.
I'm trying to use this, so I went to "etc / GMT", but when I use the output, it looks like ...
But I do not want too much +0.00. If I use the abbreviation, it does not show +0.00, etc. / Greenwich. Both of these options seem to be bad, because one is clearly incorrect given the document (GMT), and one of them is too location specific (etc / greenwich). Another crop option of +0.00 is also not a good solution.
Why abbreviations are no longer supported, and what is the correct TimeZone if I do not want +0.00
Using Java 1.7.51 (also groovy)
Adding Code
private String formatET(Date etDate){ StringBuilder sb = new StringBuilder(); SimpleDateFormat etFormat = new SimpleDateFormat("dd-MMM-yyy kk:mm zzz") TimeZone etTimeZone = TimeZone.getTimeZone("America/New_York") etFormat.setTimeZone(etTimeZone) sb.append(etFormat.format(etDate)) TimeZone gmtTimeZone = TimeZone.getTimeZone("etc/GMT") SimpleDateFormat gmtFormat = new SimpleDateFormat("kk:mm zzz") gmtFormat.setTimeZone(gmtTimeZone) sb.append(" (${gmtFormat.format(etDate)})") sb.toString(); }
This returns the following ...
11-Aug-14 11:48 EDT (15:48 GMT + 00: 00)
I tried to add it to this ...
import java.text.SimpleDateFormat; import java.util.*; public class HelloWorld{ public static void main(String []args){ Date d = new Date(); SimpleDateFormat etFormat = new SimpleDateFormat("dd-MMM-yyy kk:mm zzz"); TimeZone etTimeZone = TimeZone.getTimeZone("etc/GMT"); etFormat.setTimeZone(etTimeZone); System.out.println(etFormat.format(d)); } }
And putting it here ...
http://www.compileonline.com/compile_java_online.php
And it works as we would like. When will I be back to run locally using
java version "1.7.0_51" Java (TM) SE Runtime Environment (build 1.7.0_51-b13) 64-bit Java HotSpot TM server virtual machine (build 24.51-b03, mixed mode)
I see...
19-aug-2014 15:53 ββGMT + 00: 00