Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd HH:mm");
  2.  
  3. date= new Date();
  4.  
  5. Date now = new Date();
  6. Date date = dateFormat.parse(...);
  7. if( now.compareTo( date) < 0 ) {
  8. ... date is in the future ...
  9. }
  10.  
  11. DateTime now = DateTime.now();
  12. DateTime date = dateFormat.parse(...); // see http://joda-time.sourceforge.net/userguide.html#Input_and_Output
  13. if( now.isBefore(date) ) {
  14. ... date is in the future ...
  15. }
  16.  
  17. SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm");
  18. Date date = new Date();
  19. System.out.println(dateFormat.format(date));
  20. if(date.after(dateFormat.parse("14:00"))){
  21. System.out.println("Current time greater than 14.00");
  22. }
  23.  
  24. Date yourDate = new Date();
  25. Date yourDateToCompareAgainst = new Date();
  26. Calendar calendar = Calendar.getInstance();
  27. calendar.setTime(yourDateToCompareAgainst);
  28. calendar.set(HOUR, 14);
  29.  
  30. /** You can then check for your condition */
  31. if( calendar.before(yourDate) ) {
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement