2 Replies Latest reply: Feb 14, 2013 11:35 PM by 909741 RSS

    Question on Timezone getDisplay?

    909741
      Hi,
        TimeZone tzdd = TimeZone.getTimeZone("Etc/GMT-14");
      
          System.out.println(" Display Name " + tzdd.getDisplayName() + " ID " + tzdd.getID());
      
      
         Output:
          
          Display Name GMT+14:00 ID Etc/GMT-14
      Can anyone please explain why Display Name is GMT+14 and ID is GMT-14.

      How display name becomes GMT+14? I had given GMT-14 in Timezone but how it is converted to GMT+14?

      Thanks in advance.
        • 1. Re: Question on Timezone getDisplay?
          jschellSomeoneStoleMyAlias
          Odd but it is consistent. More examples follow
              TimeZone tzdd1 = TimeZone.getTimeZone("Etc/GMT-11");
              TimeZone tzdd2 = TimeZone.getTimeZone("Etc/GMT-12");
              TimeZone tzdd3 = TimeZone.getTimeZone("Etc/GMT-13");
              TimeZone tzdd4 = TimeZone.getTimeZone("Etc/GMT-14");
          
              TimeZone tzdd5 = TimeZone.getTimeZone("Etc/GMT+11");
              TimeZone tzdd6 = TimeZone.getTimeZone("Etc/GMT+12");
              TimeZone tzdd7 = TimeZone.getTimeZone("Etc/GMT+13");
          
              System.out.println(" Display Name=" + tzdd1.getDisplayName() + "  ID=" + tzdd1.getID());
              System.out.println(" Display Name=" + tzdd2.getDisplayName() + "  ID=" + tzdd2.getID());
              System.out.println(" Display Name=" + tzdd3.getDisplayName() + "  ID=" + tzdd3.getID());
              System.out.println(" Display Name=" + tzdd4.getDisplayName() + "  ID=" + tzdd4.getID());
          
              System.out.println(" Display Name=" + tzdd5.getDisplayName() + "  ID=" + tzdd5.getID());
              System.out.println(" Display Name=" + tzdd6.getDisplayName() + "  ID=" + tzdd6.getID());
              System.out.println(" Display Name=" + tzdd7.getDisplayName() + "  ID=" + tzdd7.getID());
          Output
           Display Name=GMT+11:00  ID=Etc/GMT-11
           Display Name=GMT+12:00  ID=Etc/GMT-12
           Display Name=GMT+13:00  ID=Etc/GMT-13
           Display Name=GMT+14:00  ID=Etc/GMT-14
           Display Name=GMT-11:00  ID=Etc/GMT+11
           Display Name=GMT-12:00  ID=Etc/GMT+12
           Display Name=Greenwich Mean Time  ID=GMT
          Could be a bug. You could look a that source to see how it parses the string.
          But the above might provide a solution depending on how it behaves.
          • 2. Re: Question on Timezone getDisplay?
            909741
            Thanks for your reply, today i found this link. It explains about this problem.

            [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4813746]