Solved

how to get date + 5 minute

Posted on 2006-06-19
2
200 Views
Last Modified: 2010-04-01
the following code do the current date time from my server, however, I want to get (time + 5 minutes) .

Thanks

Date fDate= new Date();
TimeZone gmtZone = TimeZone.getTimeZone("EST");
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
format.setTimeZone(gmtZone);
String dateString = format.format(fDate);
0
Comment
Question by:salasadi
2 Comments
 
LVL 15

Accepted Solution

by:
bpmurray earned 50 total points
ID: 16937650
Try something like:

   Calendar myCal = Calendar.getInstance();
   myCal.add(Calendar.MINUTE, 5);
   Date fDate = myCal.getTime();
0
 
LVL 5

Expert Comment

by:muktajindal
ID: 17072201
           Date fDate= new Date();
            //
            long five = fDate.getTime() + 5*60*1000;
            fDate = new Date(five);
            //
            TimeZone gmtZone = TimeZone.getTimeZone("EST");
            SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
            format.setTimeZone(gmtZone);
            String dateString = format.format(fDate);
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The business world is becoming increasingly integrated with tech. It’s not just for a select few anymore — but what about if you have a small business? It may be easier than you think to integrate technology into your small business, and it’s likely…
Ransomware continues to grow in reach and sophistication, putting data everywhere at risk. Learn how to avoid being caught in its sinister clutches with these 11 key tips.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

821 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