Reputation: 365
When I am executing the following code
SimpleDateFormat sdf=new SimpleDateFormat("dd/MM/YYYY");
Date today=new Date();
String olddate="03/11/2016";
System.out.println(sdf.parse(olddate));
Why the Result is displaying Sun Dec 27 00:00:00 IST 2015.
However I was expecting Wed Nov 03 00:00:00 IST 2016.
Anyone can please explain. And how can I get the desired output.
Upvotes: 0
Views: 59
Reputation: 41200
Date format is wrong. It should be y instead of Y-
dd/MM/yyyy
For a more detailed insight view, check the link Oracle Docs and you'll see the meaning of each character we pass there.
Upvotes: 5