get Day Week and return int value - Android java.util

Android examples for java.util:Week

Description

get Day Week and return int value

Demo Code


//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import java.util.GregorianCalendar;

public class Main {
    public static int MIN_YEAR = 1970;

    public static int getDayWeek(int index) {
        int year = MIN_YEAR + index / 12;
        int month = index % 12;
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        Calendar date = new GregorianCalendar(year, month, 1);
        int dayweek = date.get(Calendar.DAY_OF_WEEK);
        return dayweek;

    }//from  ww w.  jav a  2 s .c  om
}

Related Tutorials