Today is February 1, 2011. I am trying to generate a date string for Android in the format "MM/DD/yyyy" using SimpleDateFormat. Here is my code:
Date d = new Date();
String date = (new SimpleDateFormat("MM/DD/yyyy")).format(d);
It returns the following string:
02/32/2011
What is going on here? I can't see anything that I'm doing wrong.
Use "MM/dd/yyyy". You're using the day in year instead of day in month.
http://download.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With