ExcelFileUtils { public static List<LocalDate> generateListOfDates() { List<LocalDate> result = new ArrayList<>(); LocalDate date = LocalDateTime .ofInstant(Calendar.getInstance().toInstant(), ZoneId.systemDefault()) .toLocalDate(); LocalDate monday = null; LocalDate tuesday = null; LocalDate wednesday = null; LocalDate thursday = null; LocalDate friday = null; for (int i = 0; i < 7; i++) { date = date.plus(-1, ChronoUnit.DAYS); switch (DayOfWeek.of(date.get(ChronoField.DAY_OF_WEEK))) { case MONDAY: monday = date; break; case TUESDAY: tuesday = date; break; case WEDNESDAY: wednesday = date; break; case THURSDAY: thursday = date; break; case FRIDAY: friday = date; break; default: break; } } result.add(monday); result.add(tuesday); result.add(wednesday); result.add(thursday); result.add(friday); Collections.sort(result); return result; } private  ExcelFileUtils(); static File getFile(File directory, String prefix, LocalDate date, String extension); static File getFile(File directory, String prefix, String suffix, String extension); static String getFileName(File file); static String getFileExtension(File file); static List<LocalDate> generateListOfDates();  }
@Test public void testGenerateListOfDates() throws Exception { List<LocalDate> actual = ExcelFileUtils.generateListOfDates(); actual.forEach(localDate -> { if (previous != null) { assertTrue(previous.isBefore(localDate)); } previous = localDate; }); }