DateAdd.java Source code

Java tutorial

Introduction

Here is the source code for DateAdd.java

Source

import java.util.Date;

/**
 * DateAdd -- compute the difference between two dates.
 */
public class DateAdd {
    public static void main(String[] av) {
        //+
        /** Today's date */
        Date now = new Date();

        long t = now.getTime();

        t -= 700 * 24 * 60 * 60 * 1000;

        Date then = new Date(t);

        System.out.println("Seven hundred days ago was " + then);
        //-
    }
}