get Current Month as int value - Android java.util

Android examples for java.util:Month

Description

get Current Month as int value

Demo Code


//package com.java2s;

import java.util.Calendar;

public class Main {

    public static int getCurrentMonth() {
        Calendar cal = Calendar.getInstance();
        int year = cal.get(Calendar.YEAR);
        int mouth = cal.get(Calendar.MONTH);
        int day = cal.get(Calendar.DATE);
        int currentIndex = (year - 1970) * 12 + mouth;
        return currentIndex;
    }/*  w w w. ja  v a2  s .com*/
}

Related Tutorials