/** * Calculates the date of the first epi-week of the year. */ public static LocalDate dayOfFirstEpiWeek(int year) { // The first epi week of the year ends, by definition, on the first Saturday of January, as long as it falls // at least four days into the month. // Each epi week begins on a Sunday and ends on a Saturday. // http://www.cmmcp.org/epiweek.htm LocalDate jan1 = new LocalDate(year, 1, 1); switch (jan1.getDayOfWeek()) { case MONDAY: return new LocalDate(year - 1, 12, 31); case TUESDAY: return new LocalDate(year - 1, 12, 30); case WEDNESDAY: return new LocalDate(year - 1, 12, 29); case THURSDAY: return new LocalDate(year, 1, 4); case FRIDAY: return new LocalDate(year, 1, 3); case SATURDAY: return new LocalDate(year, 1, 2); case SUNDAY: default: return new LocalDate(year, 1, 1); } }