Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd HH:mm");
- date= new Date();
- Date now = new Date();
- Date date = dateFormat.parse(...);
- if( now.compareTo( date) < 0 ) {
- ... date is in the future ...
- }
- DateTime now = DateTime.now();
- DateTime date = dateFormat.parse(...); // see http://joda-time.sourceforge.net/userguide.html#Input_and_Output
- if( now.isBefore(date) ) {
- ... date is in the future ...
- }
- SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm");
- Date date = new Date();
- System.out.println(dateFormat.format(date));
- if(date.after(dateFormat.parse("14:00"))){
- System.out.println("Current time greater than 14.00");
- }
- Date yourDate = new Date();
- Date yourDateToCompareAgainst = new Date();
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(yourDateToCompareAgainst);
- calendar.set(HOUR, 14);
- /** You can then check for your condition */
- if( calendar.before(yourDate) ) {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement