get First-day Week Of Month - Android java.util

Android examples for java.util:Week

Description

get First-day Week Of Month

Demo Code

import android.util.Log;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class Main{

    public static int getFirstdayWeekOfMonth(int year, int month) {
        Calendar calendar = Calendar.getInstance(); //0  1  2  3  4  5 6
        calendar.set(year, month - 1, 1);

        int weekDay = calendar.get(Calendar.DAY_OF_WEEK);
        weekDay = weekDay - 1;/*w  w  w. ja va2 s . c o m*/
        return weekDay;
    }

}

Related Tutorials