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) {

        // create calendar object
        Calendar cal = Calendar.getInstance();

        // displays the current date and time
        System.out.println("Current Calendar Date: " + cal.getTime());

        // use clear method to set all field values and time value as undefined.
        cal.clear();

        // print the result
        System.out.println("The calendar shows : " + cal.getTime());
    }
}