Skip to content

Instantly share code, notes, and snippets.

@irof
Last active August 29, 2015 14:24
Show Gist options
  • Save irof/c320391d605ba2ed853c to your computer and use it in GitHub Desktop.
Save irof/c320391d605ba2ed853c to your computer and use it in GitHub Desktop.
import java.time.LocalDateTime;
import java.util.Date;
import static org.junit.Assert.assertFalse;
/**
* @author irof
*/
public class DateAndDateTimeTest {
@org.junit.Test
public void testCompareDate() throws Exception {
Date date1 = new Date();
Date date2 = new Date();
assertFalse(date1.before(date2));
assertFalse(date2.before(date1));
assertFalse(date1.after(date2));
assertFalse(date2.after(date1));
}
@org.junit.Test
public void testCompareLocalDateTime() throws Exception {
LocalDateTime localDate1 = LocalDateTime.of(2015, 7, 11, 12, 34);
LocalDateTime localDate2 = LocalDateTime.of(2015, 7, 11, 12, 34);
assertFalse(localDate1.isBefore(localDate2));
assertFalse(localDate2.isBefore(localDate1));
assertFalse(localDate1.isAfter(localDate2));
assertFalse(localDate2.isAfter(localDate1));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment