Android Week Day Get getShortDaysOfWeekNames()

Here you can find the source of getShortDaysOfWeekNames()

Description

get Short Days Of Week Names

Declaration

public static String[] getShortDaysOfWeekNames() 

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 {
    public static String[] getShortDaysOfWeekNames() {
        return getDaysOfWeekNames(Locale.getDefault(), SHORT);
    }/*from w  w w .ja  v a  2 s.  co 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. monthDaysToIntWeekDays(String dayOfMonth)
  2. convertDayOfWeekFromTimeToCalendar(int timeDayOfWeek)
  3. getDayOfWeek(int index)
  4. getNumberOfDayOfWeekInDays(long days, int firstDayOfWeek, int... dayOfWeek)