Reputation: 1591
I'm working on a kind of tricky app where the day of the week is important.
To avoid to much hassle, here is my main problem:
I have a DatePickerDialog
where the user selects a date. I want to know what day of the week this date is.
I'm thinking this should be easy, but somehow I can't figure it out.
I've tried a few things like using:
Calendar.DAY_OF_WEEK
- I can only get it to return todays day
Date.parse("1.16.2012").toString("dddd")
- Didn't get this to work at all
I really don't want to create a whole new calendar just for this simple problem.
Anyone good ideas guys?
Upvotes: 2
Views: 2973
Reputation: 1834
Very quickly, the date picker gives you year, month and day:
dayOfWeek = DateFormat.format("EE", new Date(year, month, day)).toString();
Iron the bugs I probably left yourself, sorry =)
Best regards.
Upvotes: 2