### Question:
DateUtilComponent { public static int lastDate(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); return cal.getActualMaximum(Calendar.DATE); }  static Date toAfterMinute(Date currentDate, int afterMinute); static Date toBeforeMinute(Date currentDate, int beforeMinute); static int lastDate(Date date); static int lastDate(int year, int month);  }### Answer:
@Test public void dateLastTest() { int year = 2018; int month = 2; Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month); int last = DateUtilComponent.lastDate(cal.getTime()); System.out.println(String.format("%d 년 %d월 의 마지막날은 %d일 입니다.", year, month - 1, last)); Assert.assertEquals(31, last); }
@Test public void dateLastByYM() { int year = 2019; int month = 6; int last = DateUtilComponent.lastDate(year, month); System.out.println(String.format("%d 년 %d월 의 마지막날은 %d일 입니다.", year, month, last)); Assert.assertEquals(30, last); }