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

The following examples show how to use java.text.DateFormatSymbols#getShortMonths() . 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 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 2
Source File: ExtraDateStrings.java    From LGoodDatePicker with MIT License 6 votes vote down vote up
/**
 * getStandaloneMonthName, This returns a "standalone version" month name for the specified
 * month, in the specified locale. In some languages, including Russian and Czech, the
 * standalone version of the month name is different from the version of the month name you
 * would use as part of a full date. (Is different from the formatting version).
 *
 * This tries to get the standalone version first. If no mapping is found for a standalone
 * version (Presumably because the supplied language has no standalone version), then this will
 * return the formatting version of the month name.
 */
private static String getStandaloneMonthName(Month month, Locale locale, boolean capitalize,
        boolean shortVersion) {
    // Attempt to get the standalone version of the month name.
    TextStyle style = (shortVersion) ? TextStyle.SHORT_STANDALONE : TextStyle.FULL_STANDALONE;
    String monthName = month.getDisplayName(style, locale);
    String monthNumber = "" + month.getValue();
    // If no mapping was found, then get the "formatting version" of the month name.
    if (monthName.equals(monthNumber)) {
        DateFormatSymbols dateSymbols = DateFormatSymbols.getInstance(locale);
        if (shortVersion) {
            monthName = dateSymbols.getShortMonths()[month.getValue() - 1];
        } else {
            monthName = dateSymbols.getMonths()[month.getValue() - 1];
        }
    }
    // If needed, capitalize the month name.
    if ((capitalize) && (monthName != null) && (monthName.length() > 0)) {
        monthName = monthName.substring(0, 1).toUpperCase(locale) + monthName.substring(1);
    }
    return monthName;
}
 
Example 3
Source File: CalendarText.java    From Time4A with Apache License 2.0 6 votes vote down vote up
@Override
public String[] months(
    String calendarType,
    Locale locale,
    TextWidth tw,
    OutputContext oc,
    boolean leapForm
) {

    DateFormatSymbols dfs = DateFormatSymbols.getInstance(locale);

    switch (tw) {
        case WIDE:
            return dfs.getMonths();
        case ABBREVIATED:
        case SHORT:
            return dfs.getShortMonths();
        case NARROW:
            return narrow(dfs.getShortMonths(), 12);
        default:
            throw new UnsupportedOperationException(tw.name());
    }

}
 
Example 4
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 5
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 6
Source File: DateTraitLayout.java    From Field-Book with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get month name based on numeric value
 */
String getMonthForInt(int m) {
    String month = "invalid";
    DateFormatSymbols dfs = new DateFormatSymbols();
    String[] months = dfs.getShortMonths();

    if (m >= 0 && m <= 11) {
        month = months[m];
    }

    return month;
}
 
Example 7
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 8
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 9
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 10
Source File: Cookie.java    From RipplePower with Apache License 2.0 5 votes vote down vote up
private long dateToTimeStamp(String date) {
	if ((date != "") && (date != null)) {
		DateFormatSymbols s = new DateFormatSymbols();
		String[] months = s.getShortMonths();
		String monthname = date.replaceAll("^\\w*, \\d\\d-", "");
		monthname = monthname.replaceAll("-[\\w|\\W]*", "");

		int monthvalue = arraySearch(monthname, months) + 1;
		String number = monthvalue + "";
		if (monthvalue < 10) {
			number = "0" + number;
		}
		date = date.replace(monthname, number);
		date = date.replaceAll("^\\w*, ", "");
		date = date.replace(" GMT", "");

		SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");
		Date d = new Date();
		try {
			d = sdf.parse(date);
		} catch (ParseException e) {
			e.printStackTrace();
			return 0;
		}
		return d.getTime();
	}
	return (System.currentTimeMillis() * 5);
}
 
Example 11
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 12
Source File: Calendar.java    From openjdk-jdk8u-backup 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 13
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 14
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 15
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 16
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 17
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 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: CustomDatePicker.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public MonthFormatter() {
    DateFormatSymbols dfs = new DateFormatSymbols();
    months = dfs.getShortMonths();
}