SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date date = (Date)formatter.parse("2011-09-13");
Log.e(MY_DEBUG_TAG, "Output is "+ date.getYear() + " /" + date.getMonth() + " / "+ (date.getDay()+1));
Is out putting
09-13 14:20:18.740: ERROR/GoldFishActivity(357): Output is 111 /8 / 3
What is the issue?
The methods you are using in the
Dateclass are deprecated.getYear()returns a value that is the result of subtracting 1900 from the year i.e.2011 - 1900 = 111.getDay()returns the day of the week and3 = Wednesday.getDate()returns the day of the month, but this too is deprecated.You should use the
Calendarclass instead.