Calculates the number of days that the given month has - Android java.util

Android examples for java.util:Month

Description

Calculates the number of days that the given month has

Demo Code


//package com.java2s;

import java.util.Calendar;

public class Main {
    /**/*w w  w  .  j a  va 2 s .  c  o m*/
     * Calculates the number of days that the given month has
     * 
     * @param a_calendar -> given month
     * @return number of days
     */
    @SuppressWarnings("static-access")
    public static int getDaysOfMonth(Calendar a_calendar) {
        Calendar l_tempCal = Calendar.getInstance();
        l_tempCal.setTimeInMillis(a_calendar.getTimeInMillis());
        l_tempCal.set(Calendar.DAY_OF_MONTH, 1);
        return l_tempCal.getActualMaximum(l_tempCal.DAY_OF_MONTH);
    }
}

Related Tutorials