private void tagFrontLoadLastPeriods() {
   List<Period> periodList = examination.getPeriodList();
   int frontLoadLastPeriodSize =
       examination.getInstitutionParametrization().getFrontLoadLastPeriodSize();
   if (frontLoadLastPeriodSize == 0) {
     return;
   }
   int minimumPeriodId = periodList.size() - frontLoadLastPeriodSize;
   if (minimumPeriodId < 0) {
     logger.warn(
         "The frontLoadLastPeriodSize ("
             + frontLoadLastPeriodSize
             + ") is bigger than periodListSize ("
             + periodList.size()
             + "). Tagging all periods as frontLoadLast...");
     minimumPeriodId = 0;
   }
   for (Period period : periodList.subList(minimumPeriodId, periodList.size())) {
     period.setFrontLoadLast(true);
   }
 }
 private void readPeriodList() throws IOException {
   int periodSize = readHeaderWithNumber("Periods");
   List<Period> periodList = new ArrayList<Period>(periodSize);
   // Everything is in the default timezone and the default locale.
   Calendar calendar = Calendar.getInstance();
   final DateFormat DATE_FORMAT = new SimpleDateFormat("dd:MM:yyyy HH:mm:ss");
   int referenceDayOfYear = -1;
   int referenceYear = -1;
   for (int i = 0; i < periodSize; i++) {
     Period period = new Period();
     period.setId((long) i);
     String line = bufferedReader.readLine();
     String[] lineTokens = line.split(SPLIT_REGEX);
     if (lineTokens.length != 4) {
       throw new IllegalArgumentException(
           "Read line (" + line + ") is expected to contain 4 tokens.");
     }
     String startDateTimeString = lineTokens[0] + " " + lineTokens[1];
     period.setStartDateTimeString(startDateTimeString);
     period.setPeriodIndex(i);
     int dayOfYear;
     int year;
     try {
       calendar.setTime(DATE_FORMAT.parse(startDateTimeString));
       calendar.get(Calendar.DAY_OF_YEAR);
       dayOfYear = calendar.get(Calendar.DAY_OF_YEAR);
       year = calendar.get(Calendar.YEAR);
     } catch (ParseException e) {
       throw new IllegalArgumentException(
           "Illegal startDateTimeString (" + startDateTimeString + ").", e);
     }
     if (referenceDayOfYear < 0) {
       referenceDayOfYear = dayOfYear;
       referenceYear = year;
     }
     if (year != referenceYear) {
       // Because the Calendar API in JSE <= 7 sucks...
       throw new IllegalStateException(
           "Not yet implemented to handle periods spread over different years...");
     }
     int dayIndex = dayOfYear - referenceDayOfYear;
     if (dayIndex < 0) {
       throw new IllegalStateException("The periods should be in ascending order.");
     }
     period.setDayIndex(dayIndex);
     period.setDuration(Integer.parseInt(lineTokens[2]));
     period.setPenalty(Integer.parseInt(lineTokens[3]));
     periodList.add(period);
   }
   examination.setPeriodList(periodList);
 }