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

The following examples show how to use java.text.DateFormatSymbols#getWeekdays() . 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: Calendar.java    From jdk-1.7-annotated with Apache License 2.0 6 votes vote down vote up
private String[] getFieldStrings(int field, int style, DateFormatSymbols symbols) {
    String[] strings = null;
    switch (field) {
    case ERA:
        strings = symbols.getEras();
        break;

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

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

    case AM_PM:
        strings = symbols.getAmPmStrings();
        break;
    }
    return strings;
}
 
Example 2
Source File: Calendar.java    From j2objc with Apache License 2.0 6 votes vote down vote up
private String[] getFieldStrings(int field, int style, DateFormatSymbols symbols) {
    String[] strings = null;
    switch (field) {
    case ERA:
        strings = symbols.getEras();
        break;

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

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

    case AM_PM:
        strings = symbols.getAmPmStrings();
        break;
    }
    return strings;
}
 
Example 3
Source File: Calendar.java    From jtransc with Apache License 2.0 6 votes vote down vote up
private String[] getDisplayNameArray(int field, int style, Locale locale) {
	if (field < 0 || field >= FIELD_COUNT) {
		throw new IllegalArgumentException("bad field " + field);
	}
	checkStyle(style);
	DateFormatSymbols dfs = DateFormatSymbols.getInstance(locale);
	switch (field) {
		case AM_PM:
			return dfs.getAmPmStrings();
		case DAY_OF_WEEK:
			return (style == LONG) ? dfs.getWeekdays() : dfs.getShortWeekdays();
		case ERA:
			return dfs.getEras();
		case MONTH:
			return (style == LONG) ? dfs.getMonths() : dfs.getShortMonths();
	}
	return null;
}
 
Example 4
Source File: Calendar.java    From openjdk-8 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: Calendar.java    From jdk1.8-source-analysis 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 6
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 7
Source File: Calendar.java    From Java8CN 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 8
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 9
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 10
Source File: CalendarRecurrenceHelper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Returns a lookup from recurrence rule days of the week, to
 *  the proper days of the week in the specified locale
 */
public static Map<String,String> buildLocalRecurrenceDaysOfTheWeek(Locale locale)
{
   // Get our days of the week, in the current locale
   DateFormatSymbols dates = new DateFormatSymbols(I18NUtil.getLocale());
   String[] weekdays = dates.getWeekdays();
   
   // And map them based on the outlook two letter codes
   Map<String,String> days = new HashMap<String, String>();
   for(Map.Entry<String,Integer> e : DAY_NAMES_TO_CALENDAR_DAYS.entrySet())
   {
      days.put(e.getKey(), weekdays[e.getValue()]);
   }
   return days;
}
 
Example 11
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 12
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 13
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 14
Source File: Calendar.java    From JDKSourceCode1.8 with MIT License 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 15
Source File: Calendar.java    From jdk8u60 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 16
Source File: Calendar.java    From TencentKona-8 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 17
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 18
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 19
Source File: AddSectionsBean.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
protected void initDaysOfWeek(){
   ResourceLoader rl = new ResourceLoader();
   DateFormatSymbols dfs = DateFormatSymbols.getInstance(rl.getLocale());
   daysOfWeek = dfs.getWeekdays();
}
 
Example 20
Source File: dayOfWeekAsString.java    From openbd-core with GNU General Public License v3.0 4 votes vote down vote up
public cfData execute(cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException {

		int weekDay = getNamedIntParam(argStruct, "dayOfWeek", 1);
		if (weekDay < 1 || weekDay > 7)
			throwException(_session, "Day must be within 1 and 7");

		DateFormatSymbols dfs = new DateFormatSymbols(_session.getLocale());
		String[] weekdays = dfs.getWeekdays();

		String weekDayString = "";
		switch (weekDay) {
		case 0:
			weekDayString = weekdays[Calendar.SATURDAY];
			break;
		case 1:
			weekDayString = weekdays[Calendar.SUNDAY];
			break;
		case 2:
			weekDayString = weekdays[Calendar.MONDAY];
			break;
		case 3:
			weekDayString = weekdays[Calendar.TUESDAY];
			break;
		case 4:
			weekDayString = weekdays[Calendar.WEDNESDAY];
			break;
		case 5:
			weekDayString = weekdays[Calendar.THURSDAY];
			break;
		case 6:
			weekDayString = weekdays[Calendar.FRIDAY];
			break;
		case 7:
			weekDayString = weekdays[Calendar.SATURDAY];
			break;
		default:
			throw new IllegalStateException("invalid week day - " + weekDay);
		}

		return new cfStringData(weekDayString);
	}