MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

/*
The 21st century (up to Thu May 11 14:14:02 PDT 2006) is 1956 days old.
 * */

import java.util.Date;
import java.util.GregorianCalendar;

public class MainClass {

    public static void main(String[] a) throws Exception {
        Date d1 = new GregorianCalendar(2000, 11, 31, 23, 59).getTime();

        Date today = new Date();

        long diff = today.getTime() - d1.getTime();

        System.out.println(
                "The 21st century (up to " + today + ") is " + (diff / (1000 * 60 * 60 * 24)) + " days old.");
    }
}