get Day Of Week from Calendar - Android java.util

Android examples for java.util:Week

Description

get Day Of Week from Calendar

Demo Code


import android.util.Log;
import java.text.DateFormatSymbols;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Locale;

public class Main{
    private static final String LOG_TAG = CalendarUtil.class
            .getSimpleName();//  ww  w.  ja  va  2  s . c  o m
    public static Calendar getDayOfWeek(final int dayOfWeek,
            final int weekOfYear, final int year) {
        Log.d(LOG_TAG,
                "getDayOfWeek(final int dayOfWeek, final int weekOfYear, final int year) is called.");
        return getDayOfWeek(Calendar.getInstance(), dayOfWeek, weekOfYear,
                year);
    }
    private static Calendar getDayOfWeek(final Calendar c,
            final int dayOfWeek, final int weekOfYear, final int year) {
        c.clear();

        c.set(Calendar.YEAR, year);
        c.set(Calendar.WEEK_OF_YEAR, weekOfYear);
        c.set(Calendar.DAY_OF_WEEK, dayOfWeek);

        return c;
    }
}

Related Tutorials