Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Calendar;

public class Main {

    public static void main(String[] args) {

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

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

        // change year in past calendar
        past.set(Calendar.YEAR, 2013);
        System.out.println("Year is " + past.get(Calendar.YEAR));

        // check if calendar date is before current date
        System.out.println(cal.before(past));
    }
}