Java Week Day getShortWeekday(String day)

Here you can find the source of getShortWeekday(String day)

Description

Get short day string for current locale

License

GNU General Public License

Parameter

Parameter Description

Return

short day string in language of current locale

Declaration

public static String getShortWeekday(String day) 

Method Source Code

//package com.java2s;
/*/*from  www  .  j  a v a2  s.  c o m*/
 * Copyright (C) 2015  University of Oregon
 *
 * You may distribute under the terms of either the GNU General Public
 * License or the Apache License, as specified in the LICENSE file.
 *
 * For more information, see the LICENSE file.
 */

import java.util.*;

import java.text.*;

public class Main {
    /**
     * Get short day string for current locale  
     * @param   short day string in default locale (en_US)  (e.g. Mon, Tue)
     * @return  short day string in language of current locale
     */
    public static String getShortWeekday(String day) {
        DateFormatSymbols symbols;
        String[] defaultDays;
        String[] Days;

        symbols = new DateFormatSymbols(new Locale("en", "US")); // for default locale
        defaultDays = symbols.getShortWeekdays();
        symbols = new DateFormatSymbols(); // for current locale
        Days = symbols.getShortWeekdays();
        int i = 0;
        for (i = 0; i < defaultDays.length; i++) {
            if (day.equals(defaultDays[i]))
                return Days[i];
        }
        return day; // not found
    }
}

Related

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