Past and future dates
Tuesday, February 24th, 2009/**
* @(#)test.java
* test application
*/
import java.util.Date;
public class test
{
public static void main(String[] args)
{
Date now = new Date();
long past = now.getTime();
long future = now.getTime();
past -= 300 * 24 * 60 * 60 * 1000;
future += 300 * 24 * 60 * 60 * 1000;
Date pastdate = new Date(past);
Date futuredate = new Date(future);
System.out.println(”300 days ago was ” + pastdate);
System.out.println(”300 days from now will be ” + futuredate);
}
}
On my system
300 days ago was Sun Feb 22 17:51:41 GMT 2009
300 days from now will be Thu Feb 26 05:18:13 GMT 2009
