Get first day of week of Month - Android java.util

Android examples for java.util:Month

Description

Get first day of week of Month

Demo Code


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

public class Main {

    public static int getFirstDayOfWeekOfMonth() {
        Calendar calendar = Calendar.getInstance();
        //   // w  w  w  .  ja v a2  s . c  om
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        //
        return calendar.get(Calendar.DAY_OF_WEEK);
    }

    public static int getFirstDayOfWeekOfMonth(int year, int month) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, year);
        calendar.set(Calendar.MONTH, month - 1);
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        //
        return calendar.get(Calendar.DAY_OF_WEEK);
    }
}

Related Tutorials