Code example for Date

Methods: getDaygetMonthgetTimegetYear

0
    assertEquals(msg, expected.get(Calendar.MONTH), actual.get(Calendar.MONTH));
    assertEquals(msg, expected.get(Calendar.DAY_OF_MONTH), actual.get(Calendar.DAY_OF_MONTH));
  } 
   
  protected void assertDateEquals(Date expected, Date actual) {
    String msg = "Expected: " + formatter().format(expected.getTime()) + " but got: " + formatter().format(actual.getTime());
    assertEquals(msg, expected.getYear(), actual.getYear());
    assertEquals(msg, expected.getMonth(), actual.getMonth());
    assertEquals(msg, expected.getDay(), actual.getDay());
  } 
   
  protected void assertSummary(Calendar expected, String actual) {
    assertEquals(summaryFormatter().format(expected.getTime()), actual);
  } 
 
   
  private SimpleDateFormat formatter() {
    return new SimpleDateFormat("yyyy.MM.dd");
  } 
   
Stop searching for code, let great code find you!  Add Codota to your java IDE