Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import java.time.LocalDateTime;
  2. import java.util.Date;
  3.  
  4. import static org.junit.Assert.assertFalse;
  5.  
  6. /**
  7. * @author irof
  8. */
  9. public class DateAndDateTimeTest {
  10. @org.junit.Test
  11. public void testCompareDate() throws Exception {
  12. Date date1 = new Date();
  13. Date date2 = new Date();
  14.  
  15. assertFalse(date1.before(date2));
  16. assertFalse(date2.before(date1));
  17. assertFalse(date1.after(date2));
  18. assertFalse(date2.after(date1));
  19. }
  20.  
  21. @org.junit.Test
  22. public void testCompareLocalDateTime() throws Exception {
  23. LocalDateTime localDate1 = LocalDateTime.of(2015, 7, 11, 12, 34);
  24. LocalDateTime localDate2 = LocalDateTime.of(2015, 7, 11, 12, 34);
  25.  
  26. assertFalse(localDate1.isBefore(localDate2));
  27. assertFalse(localDate2.isBefore(localDate1));
  28. assertFalse(localDate1.isAfter(localDate2));
  29. assertFalse(localDate2.isAfter(localDate1));
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement