I have a string in the following format.
07/06/2011 5:06
mm/dd/yyyy hh:mm
am using following code
DateFormat dateFormater = new SimpleDateFormat("mm/dd/yyyy hh:mm");
date = (Date)dateFormater.parse(dateTimeStr);
but for input = 03/05/2011 9:45
i get op = Wed Jan 05 09:45:00 IST 2011
Why so?I gave month as march but i am getting jan as month
Whats the issue with my code?You need to change the format to MM/dd/yyyy hh:mm ref: http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
Months use capital M
- MM/dd/yyyy
- check the docs
You're aware that month
is an uppercase M
, right?
Try this one: MM/dd/yyyy hh:mm mm stands for minute in hour. But you need MM which stands for Month in year.
精彩评论