I'm trying to get the actual month from the Calendar
using the following:
Calendar c = Calendar.getInstance();
String time = String.valueOf(c.get(Calendar.MONTH));
According the system settings "Settings --> Date & Time" actual month is 10 while get(Calendar.MONTH)
returns 09.
Keep in mind that months values start from
0
, soOctober
is actually month number9
.http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Calendar.html#MONTH
Calendar.MONTH
returns
Docs
So change your code to
use this
Calendar.MONTH value starts from 0 to 11 not 1 to 12.
You may check the value of Calendar.JANUARY is 0 not 1.
Refer: http://developer.android.com/reference/java/util/Calendar.html#JANUARY
Calendar.MONTH
returns month which is zero based that is why it is giving 1 less than actual month Add 1 to get correct valueI suggest trying