Guest User

Untitled

a guest
Jan 18th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. public void test() {
  2.  
  3. Stirng t1 = "10:30 AM"; // 12-hours format
  4. Stirng t2 = "11:30 AM"; // 12-hours format
  5. <or>
  6. Stirng t1 = "10:30"; // 24-hours format
  7. Stirng t2 = "11:30"; // 24-hours format
  8.  
  9. if(t1.before(t2)) {
  10. System.out.println(t1 + " is before of " + t2);
  11. }
  12. }
  13.  
  14. SimpleDateFormat formatter = new SimpleDateFormat("HH:mm");
  15. Date time = formatter.parse("11:30");
  16.  
  17. if (new DateTime(2012, 9, 15, 10, 30).compareTo(new DateTime(2012, 9, 15, 11, 30) < 0) {
  18. // first is before second date
  19. }
  20.  
  21. if (new LocalTime(10, 30).compareTo(new LocalTime(11, 30) < 0) {
  22. // first time is before second time
  23. }
Add Comment
Please, Sign In to add comment