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

SimpleDateFormat formatting of "LLLL" in English is incorrect; should be identical to "MMMM"

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Introduced In Version:
      8
    • Resolved In Build:
      b59
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        The "stand-alone" month names ("LLLL" format) in English are expected to be identical to the "context sensitive" ("MMMM" format) month names, but instead we see only numbers.

        This program:

        import java.text.*;
        import java.util.*;

        public class September {
            public static void main(String[] args) throws Throwable {
                Date date = new SimpleDateFormat("yyyy-MM-dd").parse("2010-09-15");
                String[] formats = { "LLLL", "LLL", "LL",
                                     "MMMM", "MMM", "MM",
                };
                for (String format : formats) {
                    System.out.println(format + " -> " + new SimpleDateFormat(format, new Locale("en")).format(date));
                }
            }
        }

        prints

        LLLL -> 0009
        LLL -> 009
        LL -> 09
        MMMM -> September
        MMM -> Sep
        MM -> 09

        but we expect

        LLLL -> September
        LLL -> Sep
        LL -> 09
        MMMM -> September
        MMM -> Sep
        MM -> 09

        The month names are handled correctly in e.g. Czech.

        Spec says
        http://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html

        """
        Month: If the number of pattern letters is 3 or more, the month is interpreted as text; otherwise, it is interpreted as a number.
        """

        Workaround is to check whether LLLL yields a number and fall back to MMMM in that case.
        We have to have fall-back code anyways to continue working with jdk7.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  okutsu Masayoshi Okutsu
                  Reporter:
                  martin Martin Buchholz
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: