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

DateFormat in german locale returns wrong value for month march

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 8u40
    • core-libs
    • b57
    • x86_64
    • windows_7
    • Verified

        FULL PRODUCT VERSION :
        java version "1.8.0_40"
        Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
        Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Windows 7 Professional Service Pack 1

        A DESCRIPTION OF THE PROBLEM :
        The java.text.DateFormat.format() method returns inconsistent values for months if the Date object comes from a Calendar with german Locale and a time value in March:
        For a pattern "MMM" the format is "Mrz"
        For a pattern "MMM yyyy" the format is "Mär 2015"


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        execute the provided class

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Mär
        Mär 2015

        or

        Mrz
        Mrz 2015

        ACTUAL -
        Mrz
        Mär 2015

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.text.SimpleDateFormat;
        import java.util.Calendar;
        import java.util.GregorianCalendar;
        import java.util.Locale;

        public class CalendarLocaleMarchBug {

        public static void printDate (Calendar c, String pattern) {
        SimpleDateFormat f = new SimpleDateFormat(pattern);
        f.setCalendar(c);
        String res1 = f.format(c.getTime());
        System.out.println(res1);
        }

        public static void main(String[] args) {
        Calendar c = new GregorianCalendar(Locale.GERMAN);
        c.set(2015,02,20);
        printDate(c,"MMM");
        printDate(c,"MMM yyyy");
        }

        }
        ---------- END SOURCE ----------

              okutsu Masayoshi Okutsu
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: