I ma getting exeception while parsing the date.
following is the code:
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-DD");
Date d = format.parse("2014/02/20");
System.out.println(d);
Not only have you got the slashes/dashes wrong, you're also using DD
(day of year) instead of dd
(day of month). You want:
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
As always, read the documentation to find out exactly what pattern symbols mean - and if you find it's behaving oddly, check the pattern against the data very carefully.
I would also recommend:
java.time
(Java 8) if you possibly can; the java.util.Date/Calendar
API is horribleCurrently you're using the default time zone and locale. While the locale may not matter in this case (unless it's used to pick the calendar system; I can't remember offhand) I think it's clearer to explicitly specify it. The time zone definitely matters; if you only ever want to treat this as a date (no time) it's probably worth specifying UTC - that way it's easy to interoperate with anything else, and you get day boundaries in obvious places in the underlying millisecond representation.
See more on this question at Stackoverflow