Reputation: 6611
i try to convert string to date , but when after the conversion the month is set to jan , but in input the month is other example 'sep' . following is my code.
Date tempDate = new SimpleDateFormat("mm/dd/yyyy").parse("09/12/2014");
System.out.println("Current Date " +tempDate);
output :
Current Date Sun Jan 12 00:09:00 IST 2014
Upvotes: 2
Views: 7832
Reputation: 28588
Reference these formats Java Date Format Docs:
so mm
is to reference minutes in hour while MM
is for Month.
That is the reason you are getting:
Current Date Sun Jan 12 00:09:00 IST 2014
from ("09/12/2014")
by default month is Jan
while it set minutes to '09' due to mm
.
Upvotes: 8