Reputation: 5
DateFormat formatter = new SimpleDateFormat("yy-mm-dd");
formatter.setLenient(false);
String[] dateStr = { "2013-12-27", "2013-01-03"};
for (int i = 0; i <= 1; i++) {
Date date = formatter.parse(dateStr[i]);
System.out.println("date is "+date);
}
result : Sun Jan 27 00:12:00 IST 2013
Thu Jan 03 00:01:00 IST 2013
i am parsing string date in to Date.but it is giving me date Starting with month Jan regardless of what month i am passing to formatter constructor.
Upvotes: 0
Views: 128
Reputation: 7511
The format for your date would be yy-MM-dd
. Update your format and check.
Upvotes: 4
Reputation: 3494
once Silly Mistake
DateFormat formatter = new SimpleDateFormat("yy-MM-dd");
Format this line in your code
Upvotes: 3