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();

        // displays the current calendar
        System.out.println("Month is " + cal.get(Calendar.MONTH));

        // roll month
        cal.roll(Calendar.MONTH, true);

        // print result after rolling
        System.out.println("Month is " + cal.get(Calendar.MONTH));

        // roll downwards
        cal.roll(Calendar.MONTH, false);

        // print result after rolling down
        System.out.println("Month is " + cal.get(Calendar.MONTH));
    }
}