I started digging through the source code for SimpleDateFormat
, and read enough to glean what appears to be happening here. What is happening is that your year component 2k11
is being interpreted as a two digit year (actually one digit, 2
), and everything that follows is being ignored as not being part of the date pattern. Consider the following code which produces the same result:
DateFormat dateFormat = new SimpleDateFormat("dd MMM, yyyy");
dateFormat.setLenient(false);
Date blah = dateFormat.parse("01 Jan, 2 Jon Skeet");
System.out.println(blah);
This prints:
Sun Jan 01 00:00:00 CET 2
As you can see, the intepreted year is 2, and the Jon Skeet
blurb was ignored. To understand exactly why SimpleDateFormat
is doing this, read the source code.