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

TimeZone.getDisplayName given Locale.US doesn't always honor the Locale

XMLWordPrintable

    • b19
    • 11
    • b12
    • generic
    • generic
    • Verified

        ADDITIONAL SYSTEM INFORMATION :
        (Discovered in Apache Lucene/Solr randomized tests including locale & JVM randomization)

        A DESCRIPTION OF THE PROBLEM :
        When the default locale is Arabic, the timeZone.getDisplayName method does not honor the Locale.US argument. This is important as it's used by date.toString()!

        REGRESSION : Last worked in version 8u181

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        (see short demonstration program)

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        GMT+05:00
        ACTUAL -
        GMT+٠٥:٠٠

        ---------- BEGIN SOURCE ----------
        // RUN WITH ASSERTIONS ENABLED: -ea

        import java.util.Locale;
        import java.util.TimeZone;

        public class TestJdkBug {
          public static void main(String[] args) {
            Locale.setDefault(Locale.forLanguageTag("ar")); // (Arabic)
            TimeZone zi = TimeZone.getTimeZone("Etc/GMT-5");
            final String displayName = zi.getDisplayName(false, TimeZone.SHORT, Locale.US);
            assert "GMT+05:00".equals(displayName) : displayName;
          }
        }
        ---------- END SOURCE ----------

        FREQUENCY : always


              rgoel Rachna Goel (Inactive)
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: