Android examples for java.util:Month
Calculates the number of days that the previous month of the given one has
//package com.java2s; import java.util.Calendar; public class Main { /**/*ww w . j a va 2 s .co m*/ * Calculates the number of days that the previous month of the given one has * * @param a_calendar -> given month * @return days of the previous month */ public static int getDaysOfPreviousMonth(Calendar a_calendar) { Calendar l_tempCal = Calendar.getInstance(); l_tempCal.setTimeInMillis(a_calendar.getTimeInMillis()); l_tempCal.add(Calendar.MONTH, -1); return getDaysOfMonth(l_tempCal); } /** * 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); } }