get Current Month - Java java.util

Java examples for java.util:Month

Description

get Current Month

Demo Code


//package com.java2s;
import java.util.Calendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(getCurrentMonth());
    }/*from w ww.ja  v  a2  s .  co m*/

    public static int getCurrentMonth() {
        Calendar calendar = Calendar.getInstance();
        // month start from 0 to 11
        return calendar.get(Calendar.MONTH) + 1;
    }
}

Related Tutorials