### Question:
DateUtils { @IntRange(from = 1000, to = 9999) static int convertTwoDigitYearToFour(@IntRange(from = 0, to = 99) int inputYear) { return convertTwoDigitYearToFour(inputYear, Calendar.getInstance()); }    }### Answer:
@Test public void convertTwoDigitYearToFour_whenCurrentYearIsLessThanEighty_addsNormalBase() { Calendar earlyCenturyCalendar = Calendar.getInstance(); earlyCenturyCalendar.set(Calendar.YEAR, 2017); assertEquals(DateUtils.convertTwoDigitYearToFour(19, earlyCenturyCalendar), 2019); }
@Test public void convertTwoDigitYearToFour_whenDateIsNearCenturyButYearIsSmall_addsIncreasedBase() { Calendar lateCenturyCalendar = Calendar.getInstance(); lateCenturyCalendar.set(Calendar.YEAR, 2081); assertEquals(DateUtils.convertTwoDigitYearToFour(8, lateCenturyCalendar), 2108); }
@Test public void convertTwoDigitYearToFour_whenDateIsNearCenturyAndYearIsLarge_addsNormalBase() { Calendar lateCenturyCalendar = Calendar.getInstance(); lateCenturyCalendar.set(Calendar.YEAR, 2088); assertEquals(DateUtils.convertTwoDigitYearToFour(95, lateCenturyCalendar), 2095); }
@Test public void convertTwoDigitYearToFour_whenDateIsEarlyCenturyAndYearIsLarge_addsLowerBase() { Calendar earlyCenturyCalendar = Calendar.getInstance(); earlyCenturyCalendar.set(Calendar.YEAR, 2502); assertEquals(DateUtils.convertTwoDigitYearToFour(95, earlyCenturyCalendar), 2495); earlyCenturyCalendar.set(Calendar.YEAR, 2017); assertEquals(DateUtils.convertTwoDigitYearToFour(99, earlyCenturyCalendar), 1999); }
@Test public void convertTwoDigitYearToFour_whenDateIsMidCenturyAndYearIsLarge_addsNormalBase() { Calendar midCenturyCalendar = Calendar.getInstance(); midCenturyCalendar.set(Calendar.YEAR, 3535); assertEquals(DateUtils.convertTwoDigitYearToFour(99, midCenturyCalendar), 3599); }