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

DateTimeFormatter::ofLocalizedDate incorrect SHORT formatted dates for nl_NL

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      A DESCRIPTION OF THE PROBLEM :
      DateTimeFormatter for Netherlands locale is producing dates for format: dd-m-yy, when it should be dd-mm-yyyy

      https://en.wikipedia.org/wiki/Date_and_time_notation_in_the_Netherlands

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use the DateTimeFormater to create a SHORT date with the locale nl_NL for the date 16-08-2019 (dd-mm-yyyy)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      "16-08-2019"
      ACTUAL -
      "16-8-19"

      ---------- BEGIN SOURCE ----------
      import java.time.LocalDate;
      import java.time.format.DateTimeFormatter;
      import java.time.format.FormatStyle;
      import java.util.Locale;

      class Scratch {
          public static void main(String[] args) {
              Locale netherlandsLocale = new Locale("nl", "NL");
              final String dateString = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT)
                  .withLocale(netherlandsLocale)
                  .format(LocalDate.of(2019, 8, 16));
              System.out.println("Date strings match: " + dateString.equals("16-08-2019"));
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Format the string yourself when you see an NL locale

        Attachments

          Activity

            People

            Assignee:
            psonal Pallavi Sonal (Inactive)
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: