// ISODateYearArrayGenerator.java Copyright (c) Kari Laitinen // http://www.naturalprogramming.com // 2016-01-26 File created. // 2020-03-11 Last modification /* The Gregorian Calendar, that most countries of the world use, is such that it actually consists of 14 different types of calendars, which can be denoted with numbers from 1 to 14 in the following way: 1 Non-Leap Year starting with Monday 2 Non-Leap Year starting with Tuesday 3 Non-Leap Year starting with Wednesday 4 Non-Leap Year starting with Thursday 5 Non-Leap Year starting with Friday 6 Non-Leap Year starting with Saturday 7 Non-Leap Year starting with Sunday 8 Leap Year starting with Monday 9 Leap Year starting with Tuesday 10 Leap Year starting with Wednesday 11 Leap Year starting with Thursday 12 Leap Year starting with Friday 13 Leap Year starting with Saturday 14 Leap Year starting with Sunday This program goes through many many years and prints the calendar type code for each year. The output data of this program is used in ISODate.java */ import java.time.* ; // for classes LocalDate, Period import java.time.temporal.WeekFields ; import java.util.Scanner ; class ISODateYearArrayGenerator { public static void main( String[] not_in_use ) { Scanner keyboard = new Scanner( System.in ) ; int number_of_year_codes_on_current_line = 0 ; System.out.print( "\n " ) ; for ( int year = 2001 ; year <= 2400 ; year ++ ) { LocalDate first_day_of_year = LocalDate.of( year, 1, 1 ) ; int year_code = first_day_of_year.getDayOfWeek().getValue() ; if ( first_day_of_year.isLeapYear() ) { year_code = year_code + 7 ; } System.out.printf( "%3d,", year_code ) ; number_of_year_codes_on_current_line ++ ; if ( number_of_year_codes_on_current_line >= 20 ) { number_of_year_codes_on_current_line = 0 ; System.out.print( "\n " ) ; } } } }