Getting instance of Date 30 minutes in the future using Java

Posted on 2006-04-18
Last Modified: 2012-06-21
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.
Question by:sb1977
    LVL 92

    Accepted Solution

    Calendar cal = Calendar.getInstance();
    Date now = Calendar.getTime();
    cal.add(Calendar.MINUTE, 30);
    Date in30minutes = cal.getTime();


    Author Comment

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now