Java Date Long Format getLongWeekday(int dayOfWeek)

Here you can find the source of getLongWeekday(int dayOfWeek)

Description

Return the long name of the weekday

License

Apache License

Parameter

Parameter Description
dayOfWeek - values from 1 to 7 accepted (1 = Sunday, 7 = Saturday, 0 = [empty])

Declaration

public static String getLongWeekday(int dayOfWeek) 

Method Source Code

//package com.java2s;
/*//  w w w.  j a  va  2 s.  c o m
* Copyright 2009-2011 Telkku.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import java.text.DateFormatSymbols;
import java.util.*;

public class Main {
    /**
     * Return the long name of the weekday
     * @param dayOfWeek - values from 1 to 7 accepted (1 = Sunday, 7 = Saturday, 0 = [empty])
     * */
    public static String getLongWeekday(int dayOfWeek) {
        return getLongWeekday(dayOfWeek, Locale.getDefault());
    }

    /**
     * Return the long name of the weekday
     * @param dayOfWeek - values from 1 to 7 accepted (1 = Sunday, 7 = Saturday, 0 = [empty])
     * @param locale - 
     * */
    public static String getLongWeekday(int dayOfWeek, Locale locale) {
        DateFormatSymbols symbols = new DateFormatSymbols(locale);
        String[] longs = symbols.getWeekdays();

        String today = longs[dayOfWeek];
        today = today.substring(0, 1).toUpperCase() + today.substring(1, today.length()).toLowerCase(); //First letter upper case, others lower case
        return today;
    }
}

Related

  1. getLongMillis(String date)
  2. getLongNowTime()
  3. getLongOracleDateTime(Date date)
  4. getLongPattern(final Locale locale)
  5. getLongTime()