Getting Olson time zone name
Hello,
Could someone help and tell me how do I get Olson time zone name in Java application? I.e. I need to get the name in format like MST7MDT or PST8PDT etc.
I tried something in vein of:
TimeZone.getDefault().getDisplayName(true,
TimeZone.SHORT);
but it produces only 3-letter, deprecated name. Any clues? Thanks!
Thank you. It does work in your example, but how to determine what zone is the system in? Should I know the name of the zone, I wouldn't need to ask.
System.out.println(TimeZone.getDefault().getID());
System.out.println(TimeZone.getTimeZone("PST8PDT").getID());
System.out.println(TimeZone.getDefault().hasSameRules(TimeZone.getTimeZone("PST8PDT")));
Produces:
America/Los_Angeles
PST8PDT
false