Java SimpleDateFormat returns unexpected result

Viewed 1770

I'm trying to use SimpleDateFormat of Java to parse a String to date with the following code.

public class DateTester {

    public static void main(String[] args) throws ParseException {
        String dateString = "2011-02-28";

        SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");

        System.out.println(dateFormat.parse(dateString));
    }
}

I was expecting some parse error. But interestingly, it prints the following String.

Wed Jul 02 00:00:00 IST 195

Couldn't reason it out. Can anyone help?

Thanks

3 Answers
Related