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

DateTimeFormatter cannot use japanese.FirstYear

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 8
    • core-libs
    • None
    • generic
    • generic

      TESTCASE DESCRIPTION:
      --- FirstYearTest.java -------------
      import java.time.chrono.JapaneseChronology;
      import java.time.chrono.JapaneseDate;
      import java.time.format.DateTimeFormatter;
      import java.text.SimpleDateFormat;
      import java.util.Calendar;
      import java.util.Locale;

      public class FirstYearTest{
          static Locale jplocale;

          public static void main(String[] args){
              jplocale = new Locale("ja", "JP", "JP");
              String str;
              String pattern = "GGGGyyyy\u5e74";

              System.out.println("--- Calendar SimpleDateFormst ---");
              Calendar cal = Calendar.getInstance();
              cal.set(1989,0,8); // = Heisei 1

              SimpleDateFormat format = new SimpleDateFormat(pattern, jplocale);
              str = format.format(cal.getTime());
              System.out.println("\""+pattern+"\" "+str);

              System.out.println("--- JapaneseDate DateTimeFormatter ---");
              printDateTimeFormatter("GGGGyyyy\u5e74");
              System.out.println("--- JapaneseDate DateTimeFormatter trials ---");
              printDateTimeFormatter("GGGGyyy\u5e74");
              printDateTimeFormatter("GGGGyy\u5e74");
              printDateTimeFormatter("GGGGy\u5e74");
          }

          static void printDateTimeFormatter(String pattern) {
              JapaneseDate date = JapaneseDate.of(1989,1,8);
              String str = date.format(DateTimeFormatter.ofPattern(pattern)
                                  .withLocale(jplocale));
              System.out.println("\""+pattern+"\" "+str);
          }
      }

      FALING OUTPUT:
      --- Calendar SimpleDateFormst ---
      "GGGGyyyy\u5e74" \u5e73\u6210\u5143\u5e74
      --- JapaneseDate DateTimeFormatter ---
      "GGGGyyyy\u5e74" \u5e73\u62100001\u5e74


      Expected Result:
      --- Calendar SimpleDateFormst ---
      "GGGGyyyy\u5e74" \u5e73\u6210\u5143\u5e74
      --- JapaneseDate DateTimeFormatter ---
      "GGGGyyyy\u5e74" \u5e73\u6210\u5143\u5e74

            naoto Naoto Sato
            luchsh Jonathan Lu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: