Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 295
  • Last Modified:

Getting instance of Date 30 minutes in the future using Java

Hello - I need to compare a Date object against a Date object 30 minutes from now in the future, but I'm not sure how to get the date future date instance correct.
0
sb1977
Asked:
sb1977
1 Solution
 
objectsCommented:
Calendar cal = Calendar.getInstance();
Date now = Calendar.getTime();
cal.add(Calendar.MINUTE, 30);
Date in30minutes = cal.getTime();

0
 
sb1977Author Commented:
Great, that worked!  I just had to change "Calendar" to "cal" in line 2.  Thanks alot!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now