Java Day getDayNames(Locale locale)

Here you can find the source of getDayNames(Locale locale)

Description

Returns a List of day name Strings - suitable for calendar headings.

License

Apache License

Parameter

Parameter Description
locale a parameter

Return

List of day name Strings

Declaration

public static List<String> getDayNames(Locale locale) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

import java.util.List;
import java.util.Locale;

public class Main {
    /**/* w  w  w. jav  a 2 s  .  c  o m*/
     * Returns a List of day name Strings - suitable for calendar headings.
     *
     * @param locale
     * @return List of day name Strings
     */
    public static List<String> getDayNames(Locale locale) {
        Calendar tempCal = Calendar.getInstance(locale);
        tempCal.set(Calendar.DAY_OF_WEEK, tempCal.getFirstDayOfWeek());
        SimpleDateFormat dateFormat = new SimpleDateFormat("EEEE", locale);
        List<String> resultList = new ArrayList<String>();
        for (int i = 0; i < 7; i++) {
            resultList.add(dateFormat.format(tempCal.getTime()));
            tempCal.roll(Calendar.DAY_OF_WEEK, 1);
        }
        return resultList;
    }
}

Related

  1. getDayFormat(Date date)
  2. getDayInWeekBeginAndEnd(Date date)
  3. getDayInWeekForMonthIn2Characters(int year, int month)
  4. getDayName(String dateString)
  5. getDayNameForDate(java.util.Date dt, boolean fullname)
  6. getDayNumber()
  7. getDayOfDate(Date date)
  8. getDayOffset(String date, int offset, String format)
  9. getDayofTheDate(Date d1)