int year = LocalDate.now ().getYear (); That code depends on the JVM's current default time zone. The default zone is used in determining what today’s date is. Remember, for example, that in the moment after midnight in Paris the date in Montréal is still 'yesterday'.
Mkyong.com has provided Java and Spring tutorials, guides, and code snippets since 2008. All published articles are simple, easy to understand, and well-tested in our development environment. Mkyong.com licenses all source code on this website under the MIT License .
1. Overview. In this quick tutorial, we’ll study several ways to iterate over a range of dates, using a start and end date, in Java 7, Java 8, and Java 9. 2. Java 7. Starting with Java 7, we’ll use the class java.util.Date for holding the date values and java.util.Calendar for incrementing from one date to the next.