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

The following examples show how to use java.text.DateFormatSymbols#getEras() . 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 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 2
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 3
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 4
Source File: Calendar.java    From openjdk-8-source 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: 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 6
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 7
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 8
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 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: 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 11
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 12
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 13
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 14
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 15
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 16
Source File: bug4117335.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception
{
    DateFormatSymbols symbols = new DateFormatSymbols(Locale.JAPAN);
    String[] eras = symbols.getEras();
    System.out.println("BC = " + eras[0]);
    if (!eras[0].equals(bc)) {
        System.out.println("*** Should have been " + bc);
        throw new Exception("Error in BC");
    }
    System.out.println("AD = " + eras[1]);
    if (!eras[1].equals(ad)) {
        System.out.println("*** Should have been " + ad);
        throw new Exception("Error in AD");
    }
    String[][] zones = symbols.getZoneStrings();
    for (int i = 0; i < zones.length; i++) {
        if (!"Asia/Tokyo".equals(zones[i][0])) {
            continue;
        }
        System.out.println("Long zone name = " + zones[i][1]);
        if (!zones[i][1].equals(jstLong)) {
            System.out.println("*** Should have been " + jstLong);
            throw new Exception("Error in long TZ name");
        }
        System.out.println("Short zone name = " + zones[i][2]);
        if (!zones[i][2].equals(jstShort)) {
            System.out.println("*** Should have been " + jstShort);
            throw new Exception("Error in short TZ name");
        }
        System.out.println("Long zone name = " + zones[i][3]);
        if (!zones[i][3].equals(jdtLong)) {
            System.out.println("*** Should have been " + jdtLong);
            throw new Exception("Error in long TZ name");
        }
        System.out.println("SHORT zone name = " + zones[i][4]);
        if (!zones[i][4].equals(jdtShort)) {
            System.out.println("*** Should have been " + jdtShort);
            throw new Exception("Error in short TZ name");
        }
    }
}
 
Example 17
Source File: bug4117335.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception
{
    DateFormatSymbols symbols = new DateFormatSymbols(Locale.JAPAN);
    String[] eras = symbols.getEras();
    System.out.println("BC = " + eras[0]);
    if (!eras[0].equals(bc)) {
        System.out.println("*** Should have been " + bc);
        throw new Exception("Error in BC");
    }
    System.out.println("AD = " + eras[1]);
    if (!eras[1].equals(ad)) {
        System.out.println("*** Should have been " + ad);
        throw new Exception("Error in AD");
    }
    String[][] zones = symbols.getZoneStrings();
    for (int i = 0; i < zones.length; i++) {
        if (!"Asia/Tokyo".equals(zones[i][0])) {
            continue;
        }
        System.out.println("Long zone name = " + zones[i][1]);
        if (!zones[i][1].equals(jstLong)) {
            System.out.println("*** Should have been " + jstLong);
            throw new Exception("Error in long TZ name");
        }
        System.out.println("Short zone name = " + zones[i][2]);
        if (!zones[i][2].equals(jstShort)) {
            System.out.println("*** Should have been " + jstShort);
            throw new Exception("Error in short TZ name");
        }
        System.out.println("Long zone name = " + zones[i][3]);
        if (!zones[i][3].equals(jdtLong)) {
            System.out.println("*** Should have been " + jdtLong);
            throw new Exception("Error in long TZ name");
        }
        System.out.println("SHORT zone name = " + zones[i][4]);
        if (!zones[i][4].equals(jdtShort)) {
            System.out.println("*** Should have been " + jdtShort);
            throw new Exception("Error in short TZ name");
        }
    }
}
 
Example 18
Source File: bug4117335.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception
{
    DateFormatSymbols symbols = new DateFormatSymbols(Locale.JAPAN);
    String[] eras = symbols.getEras();
    System.out.println("BC = " + eras[0]);
    if (!eras[0].equals(bc)) {
        System.out.println("*** Should have been " + bc);
        throw new Exception("Error in BC");
    }
    System.out.println("AD = " + eras[1]);
    if (!eras[1].equals(ad)) {
        System.out.println("*** Should have been " + ad);
        throw new Exception("Error in AD");
    }
    String[][] zones = symbols.getZoneStrings();
    for (int i = 0; i < zones.length; i++) {
        if (!"Asia/Tokyo".equals(zones[i][0])) {
            continue;
        }
        System.out.println("Long zone name = " + zones[i][1]);
        if (!zones[i][1].equals(jstLong)) {
            System.out.println("*** Should have been " + jstLong);
            throw new Exception("Error in long TZ name");
        }
        System.out.println("Short zone name = " + zones[i][2]);
        if (!zones[i][2].equals(jstShort)) {
            System.out.println("*** Should have been " + jstShort);
            throw new Exception("Error in short TZ name");
        }
        System.out.println("Long zone name = " + zones[i][3]);
        if (!zones[i][3].equals(jdtLong)) {
            System.out.println("*** Should have been " + jdtLong);
            throw new Exception("Error in long TZ name");
        }
        System.out.println("SHORT zone name = " + zones[i][4]);
        if (!zones[i][4].equals(jdtShort)) {
            System.out.println("*** Should have been " + jdtShort);
            throw new Exception("Error in short TZ name");
        }
    }
}
 
Example 19
Source File: GJLocaleSymbols.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param locale must not be null
 */
private GJLocaleSymbols(Locale locale) {
    iLocale = new WeakReference<Locale>(locale);
    
    DateFormatSymbols dfs = DateTimeUtils.getDateFormatSymbols(locale);
    
    iEras = dfs.getEras();
    iDaysOfWeek = realignDaysOfWeek(dfs.getWeekdays());
    iShortDaysOfWeek = realignDaysOfWeek(dfs.getShortWeekdays());
    iMonths = realignMonths(dfs.getMonths());
    iShortMonths = realignMonths(dfs.getShortMonths());
    iHalfday = dfs.getAmPmStrings();

    Integer[] integers = new Integer[13];
    for (int i=0; i<13; i++) {
        integers[i] = Integer.valueOf(i);
    }

    iParseEras = new TreeMap<String, Integer>(String.CASE_INSENSITIVE_ORDER);
    addSymbols(iParseEras, iEras, integers);
    if ("en".equals(locale.getLanguage())) {
        // Include support for parsing "BCE" and "CE" if the language is
        // English. At some point Joda-Time will need an independent set of
        // localized symbols and not depend on java.text.DateFormatSymbols.
        iParseEras.put("BCE", integers[0]);
        iParseEras.put("CE", integers[1]);
    }

    iParseDaysOfWeek = new TreeMap<String, Integer>(String.CASE_INSENSITIVE_ORDER);
    addSymbols(iParseDaysOfWeek, iDaysOfWeek, integers);
    addSymbols(iParseDaysOfWeek, iShortDaysOfWeek, integers);
    addNumerals(iParseDaysOfWeek, 1, 7, integers);

    iParseMonths = new TreeMap<String, Integer>(String.CASE_INSENSITIVE_ORDER);
    addSymbols(iParseMonths, iMonths, integers);
    addSymbols(iParseMonths, iShortMonths, integers);
    addNumerals(iParseMonths, 1, 12, integers);

    iMaxEraLength = maxLength(iEras);
    iMaxDayOfWeekLength = maxLength(iDaysOfWeek);
    iMaxShortDayOfWeekLength = maxLength(iShortDaysOfWeek);
    iMaxMonthLength = maxLength(iMonths);
    iMaxShortMonthLength = maxLength(iShortMonths);
    iMaxHalfdayLength = maxLength(iHalfday);
}
 
Example 20
Source File: bug4117335.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception
{
    DateFormatSymbols symbols = new DateFormatSymbols(Locale.JAPAN);
    String[] eras = symbols.getEras();
    System.out.println("BC = " + eras[0]);
    if (!eras[0].equals(bc)) {
        System.out.println("*** Should have been " + bc);
        throw new Exception("Error in BC");
    }
    System.out.println("AD = " + eras[1]);
    if (!eras[1].equals(ad)) {
        System.out.println("*** Should have been " + ad);
        throw new Exception("Error in AD");
    }
    String[][] zones = symbols.getZoneStrings();
    for (int i = 0; i < zones.length; i++) {
        if (!"Asia/Tokyo".equals(zones[i][0])) {
            continue;
        }
        System.out.println("Long zone name = " + zones[i][1]);
        if (!zones[i][1].equals(jstLong)) {
            System.out.println("*** Should have been " + jstLong);
            throw new Exception("Error in long TZ name");
        }
        System.out.println("Short zone name = " + zones[i][2]);
        if (!zones[i][2].equals(jstShort)) {
            System.out.println("*** Should have been " + jstShort);
            throw new Exception("Error in short TZ name");
        }
        System.out.println("Long zone name = " + zones[i][3]);
        if (!zones[i][3].equals(jdtLong)) {
            System.out.println("*** Should have been " + jdtLong);
            throw new Exception("Error in long TZ name");
        }
        System.out.println("SHORT zone name = " + zones[i][4]);
        if (!zones[i][4].equals(jdtShort)) {
            System.out.println("*** Should have been " + jdtShort);
            throw new Exception("Error in short TZ name");
        }
    }
}