TL; DR
LocalDate.now().plusWeeks( 1 ).isBefore( stopDate )
java.time
The modern answer uses java.time classes, not Calendar .
LocalDate
The LocalDate class represents a date value only without time and without a time zone.
The time zone is critical for determining the date. At any given moment, the date changes around the world by zone. For example, a few minutes after midnight in Paris, France is a new day, still "yesterday" in Montreal Quebec .
If no time zone is specified, the JVM implicitly applies the current default time zone. This default value may change at any time, so your results may vary. It is better to specify the desired / expected time zone explicitly as an argument.
Specify the time zone name in continent/region format, such as America/Montreal , Africa/Casablanca or Pacific/Auckland . Never use the abbreviation 3-4 letters, for example EST or IST , as they are not real time zones, and are not standardized and not even unique (!).
ZoneId z = ZoneId.of( "America/Montreal" ); LocalDate today = LocalDate.now( z ); LocalDate weekLater = today.plusWeeks( 1 ) ;
Get the start date. You can specify the month for the number with the desired number 1-12 for January-December, in contrast to the crazy zero numbering in the inherited class.
LocalDate start = LocalDate.of( 2017 , 2 , 23 ) ; // Month is 1-12 for January-December.
Or, better, use Month predefined enumeration objects, one for each month of the year.
LocalDate start = LocalDate.of( 2017 , Month.FEBRUARY , 23 ) ;
From there, the loop is just basic Java, using LocalDate object comparison methods: isBefore , isAfter and isEqual .
LocalDate ld = start ; while( ld.isBefore( today ) ) { ld = ld.plusWeeks( 1 ) ; … }
About java.time
The java.time framework is built into Java 8 and later. These classes supersede the nasty old legacy datetime classes such as java.util.Date , Calendar and SimpleDateFormat .
The Joda-Time project, now in maintenance mode , we recommend switching to the java.time classes.
To learn more, see the Oracle Tutorial . And search for qaru for many examples and explanations. JSR 310 specification .
Where to get java.time classes?
The ThreeTen-Extra project extends java.time with additional classes. This project is proof of possible future additions to java.time. Here you can find useful classes such as Interval , YearWeek , YearQuarter and more .