java.text.DateFormatSymbols#getEras ( )源码实例Demo

下面列出了java.text.DateFormatSymbols#getEras ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: j2objc   文件: Calendar.java
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;
}
 
源代码2 项目: jdk1.8-source-analysis   文件: Calendar.java
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;
}
 
源代码3 项目: dragonwell8_jdk   文件: Calendar.java
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;
}
 
源代码4 项目: TelePlus-Android   文件: FastDateParser.java
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;
}
 
源代码5 项目: TencentKona-8   文件: Calendar.java
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;
}
 
源代码6 项目: jdk8u60   文件: Calendar.java
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;
}
 
源代码7 项目: JDKSourceCode1.8   文件: Calendar.java
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;
}
 
源代码8 项目: TelePlus-Android   文件: FastDateParser.java
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;
}
 
源代码9 项目: jdk8u_jdk   文件: Calendar.java
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;
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: Calendar.java
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;
}
 
源代码11 项目: jdk8u-jdk   文件: Calendar.java
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;
}
 
源代码12 项目: jdk8u-jdk   文件: Calendar.java
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;
}
 
源代码13 项目: common-utils   文件: LocaledDateFormat.java
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();
}
 
源代码14 项目: openjdk-8-source   文件: Calendar.java
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;
}
 
源代码15 项目: openjdk-8   文件: Calendar.java
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;
}
 
源代码16 项目: jdk8u_jdk   文件: bug4117335.java
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");
        }
    }
}
 
源代码17 项目: TencentKona-8   文件: bug4117335.java
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");
        }
    }
}
 
源代码18 项目: openjdk-jdk8u   文件: bug4117335.java
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");
        }
    }
}
 
源代码19 项目: openjdk-jdk9   文件: bug4117335.java
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");
        }
    }
}
 
源代码20 项目: astor   文件: GJLocaleSymbols.java
/**
 * @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);
}