Reputation: 2677
I get a date and want to check if it is the next sunday.I found alot of code with Calendar etc, but I can't find the right code. And I don't really understand how I can know if it is the next sunday from a date.
Thanks for you help
Upvotes: 2
Views: 934
Reputation: 2095
With Lamma Date it's very easy to first obtain next Sunday, then we can use equals
check if the date is next Sunday.
Date today = new Date(2014, 7, 1); // assume today is 2014-07-01
Date nextSunday = today.next(DayOfWeek.SUNDAY); // 2014-07-06
Upvotes: 0
Reputation: 12054
this might be helpful to you , you can chek by dayOfWeek == Calendar.SUNDAY after adding one day
Upvotes: 0
Reputation: 38759
First of, I recommend Joda Time as a much better Date/Time API than Calendar
.
As for your processing it breaks down into easy steps:
DateTime
objects for the two datesUpvotes: 3
Reputation: 308743
Break the problem down:
new Date();
Upvotes: 3