Thursday, January 31, 2013

Bug in SimpleDateFormat in OpenJDK

Good evening,

today I have found an interesting bug in OpenJDK. So I have the next code:

public class TestCalendar {

 public static void main(String argc[]) {
  Calendar cal = Calendar.getInstance();
  DateFormat sdf = new SimpleDateFormat("MMMMM");
  
  for (int i = 0; i < 12; i++) {
   cal.set(Calendar.MONTH, i);
   System.out.println(sdf.format(cal.getTime()));
  }
 }
}

When executing this code on

OpenJDK Runtime Environment (IcedTea7 2.3.4) (7u9-2.3.4-0ubuntu1.12.10.1)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)

The result is following:

January
March
March
April
May
June
July
August
September
October
November
December

Nice bug, I hope it is already reported, but will check if not.

Cheers!

No comments:

Post a Comment