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 ----------