fork(3) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. import java.time.* ;
  8. import java.time.format.* ;
  9. import java.time.temporal.* ;
  10.  
  11.  
  12. /* Name of the class has to be "Main" only if the class is public. */
  13. class Ideone
  14. {
  15. public static void main (String[] args) throws java.lang.Exception
  16. {
  17.  
  18. String startInput = "2014/09/12 00:00";
  19. String stopInput = "2014/09/13 00:00";
  20.  
  21. DateTimeFormatter f = DateTimeFormatter.ofPattern( "uuuu/MM/dd HH:mm" );
  22.  
  23. LocalDateTime start = LocalDateTime.parse( startInput , f ) ;
  24. LocalDateTime stop = LocalDateTime.parse( stopInput , f ) ;
  25. boolean isBefore = start.isBefore( stop ) ;
  26.  
  27. System.out.println( start + " is before " + stop + " = " + isBefore );
  28.  
  29.  
  30. }
  31. }
Success #stdin #stdout 0.18s 38824KB
stdin
Standard input is empty
stdout
2014-09-12T00:00 is before 2014-09-13T00:00 = true