I'm a beginner in programming and this is my first question to my android project in java.
I'd like to create a Spinner with 7 items. These items shall display the last seven days. Well - today is Tuesday, the entries should be like this:
today - Monday - Sunday - Saturday - .... - Wednesday
My calculation is right and the days are listed downward. But when I log the 'DAY_OF_WEEK' the result is always 7 (Saturday) and I have no idea why.
That's why my items are listed as -today- -Friday- -Thusday- ... everyday!
TimeZone/PhoneDate/PhoneTime ... everything seems okay
calendar = Calendar.getInstance();
// CalendarState for DayOfWeek: Sunday 1, Monday 2, ... Saturday 7
int currentDay = calendar.DAY_OF_WEEK;
logger.severe("CURRENT DAY OF WEEK: " + currentDay);
Maybe you notice my mistake? Thanks a lot!!
DAY_OF_WEEK
is an enumerator value, and therefore constant.
You need to use get(DAY_OF_WEEK);
on the calendar
reference.
Try this
Calendar calendar = Calendar.getInstance();
int day = calendar.get(Calendar.DAY_OF_WEEK);
for more details . See this on developers.android page.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.