Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8024143

TimeZone.getDisplayName() doesn't return a localized name after TimeZone.toZoneId().getDisplayName() is called for the same zone.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • None
    • core-libs
    • None

      Two timezones, "Africa/Asmara" and "Africa/Asmera", share the same dislplay names in TimeZoneNames*.java as follows:
                  {"Africa/Asmara", EAT},
                  {"Africa/Asmera", EAT},

      However, TimeZone.getDisplayName() returns a different name if TimeZone.toZoneId().getDisplayname() is called for the timezone.

      Test program:
      import static java.util.Locale.FRENCH;
      import static java.time.format.TextStyle.FULL;
      import static java.time.format.TextStyle.SHORT;


          public static void main(String[] args) {
              String[] zones = {"Africa/Asmara", "Africa/Asmera"};
              for (String zone : zones) {
                  TimeZone tz = TimeZone.getTimeZone(zone);
                  String name_other;

                  name_other = tz.getDisplayName(false, TimeZone.LONG, FRENCH);
                  System.out.println(name_other);

                  name_other = tz.getDisplayName(false, TimeZone.SHORT, FRENCH);
                  System.out.println(name_other);

                  name_other = tz.getDisplayName(true, TimeZone.LONG, FRENCH);
                  System.out.println(name_other);

                  name_other = tz.getDisplayName(true, TimeZone.SHORT, FRENCH);
                  System.out.println(name_other);


                  ZoneId id = tz.toZoneId();
                  name_other = id.getDisplayName(FULL, FRENCH);
                  System.out.println(name_other);
                  name_other = id.getDisplayName(SHORT, FRENCH);
                  System.out.println(name_other);


      Result:
      Heure d'Afrique de l'Est
      EAT
      Heure d'été d'Afrique de l'Est
      EAST
      Eastern Africa Time
      EAT

      Eastern African Time <--- must be in French
      EAT
      Eastern African Summer Time <--- must be in French
      EAST
      Eastern Africa Time
      EAT


      If to.ZoneId().getDisplayName() isn't called, a localized display name is returned for "Africa/Asmera" correctly.

            okutsu Masayoshi Okutsu
            peytoia Yuka Kamiya (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: