### Question:
Time { public static LocalDate parseDate(String date) { if (date == null) { throw new IllegalArgumentException("Date must not be null."); } String datePattern = "[0-3]?[0-9]-[0-1]?[0-9]-[1-2][0-9]{3}"; if (!date.matches(datePattern)) { throw new IllegalArgumentException("Date " + date + " is not in expected format (dd-mm-yyyy)."); } return LocalDate.parse(date, INDIAN_DATE_FORMAT); }  static LocalDate parseDate(String date); static final DateTimeFormatter INDIAN_DATE_FORMAT; }### Answer:
@Test public void should_parse_date_with_single_digit_month_and_day() { String date = "1-1-2000"; LocalDate parsedDate = Time.parseDate(date); assertEquals("Failed to parse year from date", 2000, parsedDate.getYear()); assertEquals("Failed to parse month from date", 1, parsedDate.getMonth().getValue()); assertEquals("Failed to parse day from date", 1, parsedDate.getDayOfMonth()); }
@Test(expected = IllegalArgumentException.class) public void should_not_accept_invalid_date_format() { String date = "27/07/2000"; Time.parseDate(date); }
@Test public void should_parse_date() { String date = "27-07-2000"; LocalDate parsedDate = Time.parseDate(date); assertEquals("Failed to parse year from date", 2000, parsedDate.getYear()); assertEquals("Failed to parse month from date", 7, parsedDate.getMonth().getValue()); assertEquals("Failed to parse day from date", 27, parsedDate.getDayOfMonth()); }