Android Week Get getDaysOfWeekNames(Locale l, int len)

Here you can find the source of getDaysOfWeekNames(Locale l, int len)

Description

get Days Of Week Names

Parameter

Parameter Description
l locale
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.

Declaration

public static String[] getDaysOfWeekNames(Locale l, int len) 

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  w  w  .ja v  a  2  s  .  c om*/
     * @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()
  6. getEnglishDayInWeek(Date date)
  7. getFirstDayOfFirstWeekOfMonth(final Calendar cal)