Java Week Day getShortWeekday(int dayOfWeek)

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

Description

Returns the short 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 getShortWeekday(int dayOfWeek) 

Method Source Code

//package com.java2s;
/*//from  w ww .  j av a2s  .  c  om
* 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 {
    /**
     * Returns the short name of the weekday.
     * @param dayOfWeek - values from 1 to 7 accepted (1 =Sunday, 7 = Saturday, 0 = empty)
     * */
    public static String getShortWeekday(int dayOfWeek) {
        return getShortWeekday(dayOfWeek, Locale.getDefault());
    }

    /**
     * Returns the short name of the weekday.
     * @param dayOfWeek - values from 1 to 7 accepted (1 =Sunday, 7 = Saturday, 0 = empty)
     * */
    public static String getShortWeekday(int dayOfWeek, Locale locale) {
        DateFormatSymbols symbols = new DateFormatSymbols(locale);
        String[] shorts = symbols.getShortWeekdays();

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

Related

  1. getPreviousDay(long date, int startOfWeek)
  2. getPreviousFriday(String date)
  3. getPreviousMonday(Date date, int days)
  4. getPreviousOrNextDay(String time, int dayNum)
  5. getPreWeekLastDay()
  6. getShortWeekday(String day)
  7. getSQLForWeekSunday(String weekString)
  8. getSundayOfWeek()
  9. getThisWeekMonday()