get Month Of Days - Java java.util

Java examples for java.util:Month

Description

get Month Of Days

Demo Code


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

public class Main {
    public static void main(String[] argv) throws Exception {
        int year = 2;
        int month = 2;
        System.out.println(getMonthOfDays(year, month));
    }//from w  w  w . j ava  2s . com

    public static int getMonthOfDays(int year, int month) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, year);
        calendar.set(Calendar.MONTH, month);
        return calendar.getActualMaximum(Calendar.DATE);
    }
}

Related Tutorials