Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static void main(String[] args) {

        Calendar cal = Calendar.getInstance();
        Calendar future = Calendar.getInstance();

        System.out.println("Current date: " + cal.getTime());

        future.set(Calendar.YEAR, 2015);
        System.out.println("Year is " + future.get(Calendar.YEAR));

        Date time = future.getTime();
        if (future.after(cal)) {
            System.out.println("Date " + time + " is after current date.");
        }

    }
}