get Number Of Days To Show In Previous Month Before This Month - Android java.util

Android examples for java.util:Month

Description

get Number Of Days To Show In Previous Month Before This Month

Demo Code


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

public class Main {
    public static int getNumberOfDaysToShowInPreviousMonthBeforeThisMonth(
            Date someDayInCurrentMonth) {
        Calendar monthCal = Calendar.getInstance();
        monthCal.setTime(someDayInCurrentMonth);
        monthCal.set(Calendar.DAY_OF_MONTH, 1);
        switch (monthCal.get(Calendar.DAY_OF_WEEK)) {
        case Calendar.SUNDAY:
            return 0;
        case Calendar.MONDAY:
            return 1;
        case Calendar.TUESDAY:
            return 2;
        case Calendar.WEDNESDAY:
            return 3;
        case Calendar.THURSDAY:
            return 4;
        case Calendar.FRIDAY:
            return 5;
        case Calendar.SATURDAY:
            return 6;
        default:/*from  ww w.j ava  2  s  .  co m*/
            return 0;
        }
    }
}

Related Tutorials