Reputation: 13
I am trying to get the date in Android using this code
final Date df = new Date();
final DateFormat dft;
dft = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);
final String dftX = dft.format(df).toString();
This works but it returns as 11/03/10 instead of 12/03/10. The emulator appears to be showing the correct date. What am I doing wrong?
Rick
Upvotes: 1
Views: 716
Reputation: 351
As far as I know, you must add a "+1" to your month because in Date conversion the counting month begins with "0" as Jan and ends with "11" for Dec
Upvotes: 4