Answer the question
In order to leave comments, you need to log in
How to assign a date to the day of the week?
The task is this:
There is a list of days that does not change
Monday
Tuesday
Wednesday
Etc...
Next to each day there is a textview in which the date must be passed. It is necessary to determine what day of the week it is and display the date and month in textview. Ideally, if today is Wednesday February 21, then opposite Wednesday, respectively, February 21, opposite Thursday February 22, etc... And the past days should be replaced with the dates of the next week... That is, last Tuesday should already have February 27. For clarity, this week's example:
Today is Wednesday 21 Feb. I open the app and see...
Mon ... 26 Feb
Tue ... 27 Feb
Wed ... 21 Feb
Thu ... 22 Feb
Fri ... 23 Feb
Sat ... 24 Feb
Sun ... 25 Feb
Accordingly, tomorrow opposite Wednesday will be Feb. 28.
Please help if it's not difficult to show the code using the example of one day ...
Answer the question
In order to leave comments, you need to log in
You do the list (ArrayList) 7 days of week.
Take JodaTime Get
today's day of the week int todayDayOfWeek today.getDayOfWeek() - 1 (-1 because they start at 1).
then you loop from 0 to 6 and write today.plusDays(i) into the list with index (i + todayDayOfWeek)%7. Everything, the list at you is filled as it is necessary. Good luck.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question