get Finish Month - Java java.util

Java examples for java.util:Month

Description

get Finish Month

Demo Code


//package com.java2s;

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static void main(String[] argv) throws Exception {
        int month = 2;
        System.out.println(getFinishMonth(month));
    }/*from ww w  .j  av  a2 s  . co  m*/

    public static Date getFinishMonth(int month) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.MONTH, month);
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
        return calendar.getTime();
    }
}

Related Tutorials