5

This is probably a very simple question but I dont see the problem or how to resolve it. Thank you for you help.

String date = "04/11/1972"
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/YYYY");
System.out.println(sdf.format(sdf.parse(date));

and it displays : 03/01/1972

Why? How to get back my date. it seems there is a problem with the parse which does not give the proper Date object

Thank you

4

1 回答 1

19

yyyy不适YYYY用于年份字段。这可能是问题所在!所以试试这个:

String date = "04/11/1972";
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
System.out.println(sdf.format(sdf.parse(date)));
于 2012-06-01T07:53:37.103 回答