Java Timestamp - Adding five minutes

java

Solution

Instead of starting with

new Date()

start with

new Date(System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(5))

This will give you a `Date` instance that represents your required point in time. You don't need to change any other part of your code.

Problem

looking for some help with a bit of Java code i'm working on, i have the following code which prints out the date and time: ``` Date dNow = new Date( ); // Instantiate a Date object SimpleDateFormat ft = new SimpleDateFormat ("MMM d, yyyy k:mm:ss"); // Time at server ``` Result: Mar 15, 2013 10:19:48 I'm creating a javascript counter to work from this number and countdown from 5 minutes. So i need to add 5 minues to the current date time in Java. So, if the current date time is: Mar 15, 2013 10:19:48 I need to add 5 minutes to Java so that it prints out: Mar 15, 2013 10:24:48 Any ideas?

Original source

Related problems