Java Code Examples for java.text.DateFormatSymbols#getShortWeekdays()

The following examples show how to use java.text.DateFormatSymbols#getShortWeekdays() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DateChooserPanel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Returns a panel of buttons, each button representing a day in the month. This is a sub-component of the DatePanel.
 *
 * @return the panel.
 */
private JPanel getCalendarPanel() {

  final JPanel p = new JPanel( new GridLayout( 7, 7 ) );
  final DateFormatSymbols dateFormatSymbols = new DateFormatSymbols();
  final String[] weekDays = dateFormatSymbols.getShortWeekdays();

  for ( int i = 0; i < this.WEEK_DAYS.length; i++ ) {
    p.add( new JLabel( weekDays[ this.WEEK_DAYS[ i ] ], SwingConstants.CENTER ) );
  }

  this.buttons = new JButton[ 42 ];
  for ( int i = 0; i < 42; i++ ) {
    final JButton b = new JButton( "" );
    b.setMargin( new Insets( 1, 1, 1, 1 ) );
    b.setName( Integer.toString( i ) );
    b.setFont( this.dateFont );
    b.setFocusPainted( false );
    b.putClientProperty( "JButton.buttonType", "square" ); //$NON-NLS-1$ $NON-NLS-2$
    this.buttons[ i ] = b;
    p.add( b );
  }
  return p;

}
 
Example 2
Source File: SectionDecorator.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
private List<String> getAbbreviatedDayList() {
    List<String> list = new ArrayList<String>();
    ResourceLoader rl = new ResourceLoader();
    DateFormatSymbols dfs = DateFormatSymbols.getInstance(rl.getLocale());
    String[] daysOfWeek = dfs.getShortWeekdays();
    if(meeting.isMonday())
        list.add(daysOfWeek[Calendar.MONDAY]);
    if(meeting.isTuesday())
        list.add(daysOfWeek[Calendar.TUESDAY]);
    if(meeting.isWednesday())
        list.add(daysOfWeek[Calendar.WEDNESDAY]);
    if(meeting.isThursday())
        list.add(daysOfWeek[Calendar.THURSDAY]);
    if(meeting.isFriday())
        list.add(daysOfWeek[Calendar.FRIDAY]);
    if(meeting.isSaturday())
        list.add(daysOfWeek[Calendar.SATURDAY]);
    if(meeting.isSunday())
        list.add(daysOfWeek[Calendar.SUNDAY]);
    return list;
}
 
Example 3
Source File: DaysOfWeek.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
public String toString(Context context, boolean showNever) {
    StringBuilder ret = new StringBuilder();
    if (mDays == 0) {
        return showNever ? context.getText(R.string.one_shot).toString() : "";
    }
    if (mDays == 0x7f) {
        return context.getText(R.string.every_day).toString();
    }
    int dayCount = 0, days = mDays;
    while (days > 0) {
        if ((days & 1) == 1) {
            dayCount++;
        }
        days >>= 1;
    }
    DateFormatSymbols dfs = new DateFormatSymbols();
    String[] dayList = dayCount > 1 ? dfs.getShortWeekdays() : dfs.getWeekdays();
    for (int i = 0; i < 7; i++) {
        if ((mDays & 1 << i) != 0) {
            ret.append(dayList[DAY_MAP[i]]);
            dayCount -= 1;
            if (dayCount > 0) {
                ret.append(context.getText(R.string.day_concat));
            }
        }
    }
    return ret.toString();
}
 
Example 4
Source File: Calendar.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private String[] getFieldStrings(int field, int style, DateFormatSymbols symbols) {
    int baseStyle = getBaseStyle(style); // ignore the standalone mask

    // DateFormatSymbols doesn't support any narrow names.
    if (baseStyle == NARROW_FORMAT) {
        return null;
    }

    String[] strings = null;
    switch (field) {
    case ERA:
        strings = symbols.getEras();
        break;

    case MONTH:
        strings = (baseStyle == LONG) ? symbols.getMonths() : symbols.getShortMonths();
        break;

    case DAY_OF_WEEK:
        strings = (baseStyle == LONG) ? symbols.getWeekdays() : symbols.getShortWeekdays();
        break;

    case AM_PM:
        strings = symbols.getAmPmStrings();
        break;
    }
    return strings;
}
 
Example 5
Source File: DateFormatSymbolsEx.java    From web-data-extractor with Apache License 2.0 5 votes vote down vote up
public DateFormatSymbolsEx(Locale locale) {
    DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(locale);

    months = dateFormatSymbols.getMonths();
    shortMonths = dateFormatSymbols.getShortMonths();
    weekdays = dateFormatSymbols.getWeekdays();
    shortWeekdays = dateFormatSymbols.getShortWeekdays();
    eras = dateFormatSymbols.getEras();
    ampms = dateFormatSymbols.getAmPmStrings();
}
 
Example 6
Source File: WeekdayNameDisplayAdapter.java    From FlexibleCalendar with MIT License 5 votes vote down vote up
private void initializeWeekDays(int startDayOfTheWeek) {
    DateFormatSymbols symbols = new DateFormatSymbols(FlexibleCalendarHelper.getLocale(getContext()));
    String[] weekDayList = symbols.getShortWeekdays(); // weekday list has 8 elements
    weekDayArray = new WeekDay[7];
    //reordering array based on the start day of the week
    for (int i = 1; i < weekDayList.length; i++) {
        WeekDay weekDay = new WeekDay();
        weekDay.index = i;
        weekDay.displayValue = weekDayList[i];
        int tempVal = i - startDayOfTheWeek;
        weekDayArray[tempVal < 0 ? 7 + tempVal : tempVal] = weekDay;
    }
}
 
Example 7
Source File: Calendar.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private String[] getFieldStrings(int field, int style, DateFormatSymbols symbols) {
    int baseStyle = getBaseStyle(style); // ignore the standalone mask

    // DateFormatSymbols doesn't support any narrow names.
    if (baseStyle == NARROW_FORMAT) {
        return null;
    }

    String[] strings = null;
    switch (field) {
    case ERA:
        strings = symbols.getEras();
        break;

    case MONTH:
        strings = (baseStyle == LONG) ? symbols.getMonths() : symbols.getShortMonths();
        break;

    case DAY_OF_WEEK:
        strings = (baseStyle == LONG) ? symbols.getWeekdays() : symbols.getShortWeekdays();
        break;

    case AM_PM:
        strings = symbols.getAmPmStrings();
        break;
    }
    return strings;
}
 
Example 8
Source File: Calendar.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private String[] getFieldStrings(int field, int style, DateFormatSymbols symbols) {
    int baseStyle = getBaseStyle(style); // ignore the standalone mask

    // DateFormatSymbols doesn't support any narrow names.
    if (baseStyle == NARROW_FORMAT) {
        return null;
    }

    String[] strings = null;
    switch (field) {
    case ERA:
        strings = symbols.getEras();
        break;

    case MONTH:
        strings = (baseStyle == LONG) ? symbols.getMonths() : symbols.getShortMonths();
        break;

    case DAY_OF_WEEK:
        strings = (baseStyle == LONG) ? symbols.getWeekdays() : symbols.getShortWeekdays();
        break;

    case AM_PM:
        strings = symbols.getAmPmStrings();
        break;
    }
    return strings;
}
 
Example 9
Source File: Calendar.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private String[] getFieldStrings(int field, int style, DateFormatSymbols symbols) {
    int baseStyle = getBaseStyle(style); // ignore the standalone mask

    // DateFormatSymbols doesn't support any narrow names.
    if (baseStyle == NARROW_FORMAT) {
        return null;
    }

    String[] strings = null;
    switch (field) {
    case ERA:
        strings = symbols.getEras();
        break;

    case MONTH:
        strings = (baseStyle == LONG) ? symbols.getMonths() : symbols.getShortMonths();
        break;

    case DAY_OF_WEEK:
        strings = (baseStyle == LONG) ? symbols.getWeekdays() : symbols.getShortWeekdays();
        break;

    case AM_PM:
        strings = symbols.getAmPmStrings();
        break;
    }
    return strings;
}
 
Example 10
Source File: Calendar.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private String[] getFieldStrings(int field, int style, DateFormatSymbols symbols) {
    int baseStyle = getBaseStyle(style); // ignore the standalone mask

    // DateFormatSymbols doesn't support any narrow names.
    if (baseStyle == NARROW_FORMAT) {
        return null;
    }

    String[] strings = null;
    switch (field) {
    case ERA:
        strings = symbols.getEras();
        break;

    case MONTH:
        strings = (baseStyle == LONG) ? symbols.getMonths() : symbols.getShortMonths();
        break;

    case DAY_OF_WEEK:
        strings = (baseStyle == LONG) ? symbols.getWeekdays() : symbols.getShortWeekdays();
        break;

    case AM_PM:
        strings = symbols.getAmPmStrings();
        break;
    }
    return strings;
}
 
Example 11
Source File: FastDateParser.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static String[] getDisplayNameArray(int field, boolean isLong, Locale locale) {
    DateFormatSymbols dfs = new DateFormatSymbols(locale);
    switch (field) {
        case Calendar.AM_PM:
            return dfs.getAmPmStrings();
        case Calendar.DAY_OF_WEEK:
            return isLong ? dfs.getWeekdays() : dfs.getShortWeekdays();
        case Calendar.ERA:
            return dfs.getEras();
        case Calendar.MONTH:
            return isLong ? dfs.getMonths() : dfs.getShortMonths();
    }
    return null;
}
 
Example 12
Source File: FastDateParser.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private static String[] getDisplayNameArray(int field, boolean isLong, Locale locale) {
    DateFormatSymbols dfs = new DateFormatSymbols(locale);
    switch (field) {
        case Calendar.AM_PM:
            return dfs.getAmPmStrings();
        case Calendar.DAY_OF_WEEK:
            return isLong ? dfs.getWeekdays() : dfs.getShortWeekdays();
        case Calendar.ERA:
            return dfs.getEras();
        case Calendar.MONTH:
            return isLong ? dfs.getMonths() : dfs.getShortMonths();
    }
    return null;
}
 
Example 13
Source File: FastDateParser.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private static String[] getDisplayNameArray(int field, boolean isLong, Locale locale) {
    DateFormatSymbols dfs = new DateFormatSymbols(locale);
    switch (field) {
        case Calendar.AM_PM:
            return dfs.getAmPmStrings();
        case Calendar.DAY_OF_WEEK:
            return isLong ? dfs.getWeekdays() : dfs.getShortWeekdays();
        case Calendar.ERA:
            return dfs.getEras();
        case Calendar.MONTH:
            return isLong ? dfs.getMonths() : dfs.getShortMonths();
    }
    return null;
}
 
Example 14
Source File: CalendarComposite.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void init() {
	mDFS = new DateFormatSymbols(mSettings.getLocale());
	mMonths = mDFS.getMonths();

	if (mCalendar == null)
		mCalendar = Calendar.getInstance(mSettings.getLocale());
	if (mToday == null)
		mToday = Calendar.getInstance(mSettings.getLocale());

	String[] weekdays = mDFS.getWeekdays();		
	// hebrew needs short weekdays
	if (mSettings.getLocale().getDisplayLanguage().toLowerCase().equals("hebrew")) {
		weekdays = mDFS.getShortWeekdays();
	}
	
	mDayTitles = new String[weekdays.length];
	
	boolean isCNLocale = mSettings.getLocale().equals(Locale.CHINA) || mSettings.getLocale().equals(Locale.TAIWAN);
	
	for (int i = 0; i < weekdays.length; i++) {
		String weekday = weekdays[i];
		if (weekday.length() > 0) {
			if (isCNLocale) {
				mDayTitles[i] = weekday.substring(2, 3).toUpperCase();
               } else {
                   mDayTitles[i] = weekday.substring(0, 1).toUpperCase();
               }
		}
	}
}
 
Example 15
Source File: ExpCalendarUtil.java    From mCalendarView with Apache License 2.0 5 votes vote down vote up
/** ExpCalendarUtil.java
 * The number to Week
 * @param number - Number day of Week (on the code Sunday is equal 7)
 * @return [String] - abbreviated name of the days of the week
 */
public static String number2Week(int number) {
    if (number < 1 || number > 7) return null; //Day of Week 1-7
    if (number == 7) {
        number = 1;
    } else {
        number = number + 1;
    }
    final DateFormatSymbols symbols = new DateFormatSymbols(); //use user locale
    final String nameDayOfWeek = symbols.getShortWeekdays()[number]; //Short name or getWeekdays for complete name
    return nameDayOfWeek.toUpperCase(); //name to uppercase
}
 
Example 16
Source File: LocaledDateFormat.java    From common-utils with GNU General Public License v2.0 5 votes vote down vote up
public LocaledDateFormat(Locale locale) {
    DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(locale);

    months = dateFormatSymbols.getMonths();
    shortMonths = dateFormatSymbols.getShortMonths();
    weekdays = dateFormatSymbols.getWeekdays();
    shortWeekdays = dateFormatSymbols.getShortWeekdays();
    eras = dateFormatSymbols.getEras();
    ampms = dateFormatSymbols.getAmPmStrings();
}
 
Example 17
Source File: CalendarText.java    From Time4A with Apache License 2.0 5 votes vote down vote up
@Override
public String[] weekdays(
    String calendarType,
    Locale locale,
    TextWidth tw,
    OutputContext oc
) {

    DateFormatSymbols dfs = DateFormatSymbols.getInstance(locale);
    String[] result;

    switch (tw) {
        case WIDE:
            result = dfs.getWeekdays(); // 8 Elemente
            break;
        case ABBREVIATED:
        case SHORT:
            result = dfs.getShortWeekdays(); // 8 Elemente
            break;
        case NARROW:
            String[] names = // 7 Elemente
                weekdays("", locale, TextWidth.SHORT, oc);
            result = narrow(names, 7);
            break;
        default:
            throw new UnsupportedOperationException(
                "Unknown text width: " + tw);
    }

    if (result.length > 7) { // ISO-Reihenfolge erzwingen
        String sunday = result[1];
        String[] arr = new String[7];
        System.arraycopy(result, 2, arr, 0, 6);
        arr[6] = sunday;
        result = arr;
    }

    return result;

}
 
Example 18
Source File: DateTimePickerTag.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
private void writeI18NMap(Writer out) throws IOException {
    // generate i18n for the picker here
    DateFormatSymbols syms = data.getDateFormatSymbols();
    out.append("$.fn.datepicker.dates['" + data.getLocale() + "'] = {\n");

    Writer names = new StringWriter();
    Writer shortNames = new StringWriter();
    String[] nameStrings = syms.getWeekdays();
    String[] shortNameStrings = syms.getShortWeekdays();
    for (int i = Calendar.SUNDAY; i <= Calendar.SATURDAY; i++) {
        names.append(String.format(" '%s',", nameStrings[i]));
        shortNames.append(String.format(" '%s',", shortNameStrings[i]));
    }
    out.append("days:      [" + names.toString() + "],\n");
    out.append("daysShort: [" + shortNames.toString() + "],\n");
    out.append("daysMin:   [" + shortNames.toString() + "],\n");

    names = new StringWriter();
    shortNames = new StringWriter();
    nameStrings = syms.getMonths();
    shortNameStrings = syms.getShortMonths();
    for (int i = Calendar.JANUARY; i <= Calendar.DECEMBER; i++) {
        names.append(String.format(" '%s',", nameStrings[i]));
        shortNames.append(String.format(" '%s',", shortNameStrings[i]));
    }
    out.append("months:      [" + names.toString() + "],\n");
    out.append("monthsShort: [" + shortNames.toString() + "],\n");
    out.append("};\n");
}
 
Example 19
Source File: Calendar.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private String[] getFieldStrings(int field, int style, DateFormatSymbols symbols) {
    int baseStyle = getBaseStyle(style); // ignore the standalone mask

    // DateFormatSymbols doesn't support any narrow names.
    if (baseStyle == NARROW_FORMAT) {
        return null;
    }

    String[] strings = null;
    switch (field) {
    case ERA:
        strings = symbols.getEras();
        break;

    case MONTH:
        strings = (baseStyle == LONG) ? symbols.getMonths() : symbols.getShortMonths();
        break;

    case DAY_OF_WEEK:
        strings = (baseStyle == LONG) ? symbols.getWeekdays() : symbols.getShortWeekdays();
        break;

    case AM_PM:
        strings = symbols.getAmPmStrings();
        break;
    }
    return strings;
}
 
Example 20
Source File: JDayChooser.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Draws the day names of the day columnes.
 */
private void drawDayNames() {
	int firstDayOfWeek = calendar.getFirstDayOfWeek();
	DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(locale);
	dayNames = dateFormatSymbols.getShortWeekdays();

	int day = firstDayOfWeek;

	for (int i = 0; i < 7; i++) {
		if (maxDayCharacters > 0 && maxDayCharacters < 5) {
			if (dayNames[day].length() >= maxDayCharacters) {
				dayNames[day] = dayNames[day]
						.substring(0, maxDayCharacters);
			}
		}

		days[i].setText(dayNames[day]);

		if (day == 1) {
			days[i].setForeground(sundayForeground);
		} else {
			days[i].setForeground(weekdayForeground);
		}

		if (day < 7) {
			day++;
		} else {
			day -= 6;
		}
	}
}