get Number Of Days In Previous Month - Android java.util

Android examples for java.util:Month

Description

get Number Of Days In Previous Month

Demo Code


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

public class Main {
    public static int getNumberOfDaysInPreviousMonth(
            Date someDayInCurrentMonth) {
        Calendar lastMonthCal = Calendar.getInstance();
        lastMonthCal.setTime(someDayInCurrentMonth);
        lastMonthCal.add(Calendar.MONTH, -1);
        return lastMonthCal.getActualMaximum(Calendar.DAY_OF_MONTH);
    }//from   w  w  w  .j  a va 2  s .c om
}

Related Tutorials