Android Week Get getDaysOfWeekNames()

Here you can find the source of getDaysOfWeekNames()

Description

get Days Of Week Names

Declaration

public static String[] getDaysOfWeekNames() 

Method Source Code

//package com.java2s;
import static java.util.Calendar.*;
import java.text.DateFormatSymbols;
import java.util.Calendar;
import java.util.Locale;

public class Main {
    /**// w  ww .  ja  v  a2 s. c  o m
     * @param l locale
     * @param len must be SHORT or LONG
     * @return Names of the day of the week in locale dependent order. First day has index 1. Index 0 has nothing.
     */
    public static String[] getDaysOfWeekNames(Locale l, int len) {

        String[] s;
        if (len == SHORT)
            s = new DateFormatSymbols(l).getShortWeekdays();
        else
            s = new DateFormatSymbols(l).getWeekdays();

        int firstDay = Calendar.getInstance().getFirstDayOfWeek();

        if (firstDay != 1) {
            String[] buf = new String[8];

            int n = 8 - firstDay;
            System.arraycopy(s, firstDay, buf, 1, n);
            System.arraycopy(s, 1, buf, n + 1, 7 - n);
            s = buf;
        }

        return s;
    }

    public static String[] getDaysOfWeekNames() {
        return getDaysOfWeekNames(Locale.getDefault(), LONG);
    }
}

Related

  1. getDateAWeekAgo(Date date)
  2. getDateInAWeek(Date date)
  3. getWeeksSinceEpochFromJulianDay(int julianDay, int firstDayOfWeek)
  4. getStartAndEndDatesForWeek(Calendar currentDate, Calendar startDate, Calendar endDate)
  5. getDaysOfWeekNames(Locale l, int len)
  6. getEnglishDayInWeek(Date date)
  7. getFirstDayOfFirstWeekOfMonth(final Calendar cal)