Java Code Examples for sun.util.locale.provider.LocaleResources#getJavaTimeFormatData()

The following examples show how to use sun.util.locale.provider.LocaleResources#getJavaTimeFormatData() . 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: CLDRTimeZoneNameProviderImpl.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private String toGMTFormat(String id, boolean daylight, boolean isShort, Locale l) {
    TimeZone tz = ZoneInfoFile.getZoneInfo(id);
    int offset = (tz.getRawOffset() + (daylight ? tz.getDSTSavings() : 0)) / 60000;
    LocaleResources lr = LocaleProviderAdapter.forType(Type.CLDR).getLocaleResources(l);
    ResourceBundle fd = lr.getJavaTimeFormatData();

    if (offset == 0) {
        return fd.getString("timezone.gmtZeroFormat");
    } else {
        String gmtFormat = fd.getString("timezone.gmtFormat");
        String hourFormat = fd.getString("timezone.hourFormat");

        if (offset > 0) {
            hourFormat = hourFormat.substring(0, hourFormat.indexOf(";"));
        } else {
            hourFormat = hourFormat.substring(hourFormat.indexOf(";") + 1);
            offset = -offset;
        }
        hourFormat = hourFormat
            .replaceFirst("H+", (isShort ? "\\%1\\$d" : "\\%1\\$02d"))
            .replaceFirst("m+", "\\%2\\$02d");
        return MessageFormat.format(gmtFormat,
                String.format(l, hourFormat, offset / 60, offset % 60));
    }
}
 
Example 2
Source File: WeekFields.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getDisplayName(Locale locale) {
    Objects.requireNonNull(locale, "locale");
    if (rangeUnit == YEARS) {  // only have values for week-of-year
        LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                .getLocaleResources(locale);
        ResourceBundle rb = lr.getJavaTimeFormatData();
        return rb.containsKey("field.week") ? rb.getString("field.week") : name;
    }
    return name;
}
 
Example 3
Source File: WeekFields.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getDisplayName(Locale locale) {
    Objects.requireNonNull(locale, "locale");
    if (rangeUnit == YEARS) {  // only have values for week-of-year
        LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                .getLocaleResources(locale);
        ResourceBundle rb = lr.getJavaTimeFormatData();
        return rb.containsKey("field.week") ? rb.getString("field.week") : name;
    }
    return name;
}
 
Example 4
Source File: WeekFields.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Override
public String getDisplayName(Locale locale) {
    Objects.requireNonNull(locale, "locale");
    if (rangeUnit == YEARS) {  // only have values for week-of-year
        LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                .getLocaleResources(
                    CalendarDataUtility.findRegionOverride(locale));
        ResourceBundle rb = lr.getJavaTimeFormatData();
        return rb.containsKey("field.week") ? rb.getString("field.week") : name;
    }
    return name;
}
 
Example 5
Source File: WeekFields.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getDisplayName(Locale locale) {
    Objects.requireNonNull(locale, "locale");
    if (rangeUnit == YEARS) {  // only have values for week-of-year
        LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                .getLocaleResources(locale);
        ResourceBundle rb = lr.getJavaTimeFormatData();
        return rb.containsKey("field.week") ? rb.getString("field.week") : name;
    }
    return name;
}
 
Example 6
Source File: WeekFields.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getDisplayName(Locale locale) {
    Objects.requireNonNull(locale, "locale");
    if (rangeUnit == YEARS) {  // only have values for week-of-year
        LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                .getLocaleResources(locale);
        ResourceBundle rb = lr.getJavaTimeFormatData();
        return rb.containsKey("field.week") ? rb.getString("field.week") : name;
    }
    return name;
}
 
Example 7
Source File: WeekFields.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getDisplayName(Locale locale) {
    Objects.requireNonNull(locale, "locale");
    if (rangeUnit == YEARS) {  // only have values for week-of-year
        LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                .getLocaleResources(locale);
        ResourceBundle rb = lr.getJavaTimeFormatData();
        return rb.containsKey("field.week") ? rb.getString("field.week") : name;
    }
    return name;
}
 
Example 8
Source File: IsoFields.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
@Override
public String getDisplayName(Locale locale) {
    Objects.requireNonNull(locale, "locale");
    LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                                .getLocaleResources(locale);
    ResourceBundle rb = lr.getJavaTimeFormatData();
    return rb.containsKey("field.week") ? rb.getString("field.week") : toString();
}
 
Example 9
Source File: IsoFields.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getDisplayName(Locale locale) {
    Objects.requireNonNull(locale, "locale");
    LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                                .getLocaleResources(locale);
    ResourceBundle rb = lr.getJavaTimeFormatData();
    return rb.containsKey("field.week") ? rb.getString("field.week") : toString();
}
 
Example 10
Source File: WeekFields.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getDisplayName(Locale locale) {
    Objects.requireNonNull(locale, "locale");
    if (rangeUnit == YEARS) {  // only have values for week-of-year
        LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                .getLocaleResources(locale);
        ResourceBundle rb = lr.getJavaTimeFormatData();
        return rb.containsKey("field.week") ? rb.getString("field.week") : name;
    }
    return name;
}
 
Example 11
Source File: WeekFields.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getDisplayName(Locale locale) {
    Objects.requireNonNull(locale, "locale");
    if (rangeUnit == YEARS) {  // only have values for week-of-year
        LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                .getLocaleResources(locale);
        ResourceBundle rb = lr.getJavaTimeFormatData();
        return rb.containsKey("field.week") ? rb.getString("field.week") : name;
    }
    return name;
}
 
Example 12
Source File: IsoFields.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getDisplayName(Locale locale) {
    Objects.requireNonNull(locale, "locale");
    LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                                .getLocaleResources(locale);
    ResourceBundle rb = lr.getJavaTimeFormatData();
    return rb.containsKey("field.week") ? rb.getString("field.week") : toString();
}
 
Example 13
Source File: WeekFields.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getDisplayName(Locale locale) {
    Objects.requireNonNull(locale, "locale");
    if (rangeUnit == YEARS) {  // only have values for week-of-year
        LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                .getLocaleResources(locale);
        ResourceBundle rb = lr.getJavaTimeFormatData();
        return rb.containsKey("field.week") ? rb.getString("field.week") : name;
    }
    return name;
}
 
Example 14
Source File: WeekFields.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
@Override
public String getDisplayName(Locale locale) {
    Objects.requireNonNull(locale, "locale");
    if (rangeUnit == YEARS) {  // only have values for week-of-year
        LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                .getLocaleResources(locale);
        ResourceBundle rb = lr.getJavaTimeFormatData();
        return rb.containsKey("field.week") ? rb.getString("field.week") : name;
    }
    return name;
}
 
Example 15
Source File: WeekFields.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getDisplayName(Locale locale) {
    Objects.requireNonNull(locale, "locale");
    if (rangeUnit == YEARS) {  // only have values for week-of-year
        LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                .getLocaleResources(locale);
        ResourceBundle rb = lr.getJavaTimeFormatData();
        return rb.containsKey("field.week") ? rb.getString("field.week") : name;
    }
    return name;
}
 
Example 16
Source File: WeekFields.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
@Override
public String getDisplayName(Locale locale) {
    Objects.requireNonNull(locale, "locale");
    if (rangeUnit == YEARS) {  // only have values for week-of-year
        LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                .getLocaleResources(locale);
        ResourceBundle rb = lr.getJavaTimeFormatData();
        return rb.containsKey("field.week") ? rb.getString("field.week") : name;
    }
    return name;
}
 
Example 17
Source File: DateTimeTextProvider.java    From jdk8u-dev-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the localized resource of the given key and locale, or null
 * if no localized resource is available.
 *
 * @param key  the key of the localized resource, not null
 * @param locale  the locale, not null
 * @return the localized resource, or null if not available
 * @throws NullPointerException if key or locale is null
 */
@SuppressWarnings("unchecked")
static <T> T getLocalizedResource(String key, Locale locale) {
    LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                                .getLocaleResources(locale);
    ResourceBundle rb = lr.getJavaTimeFormatData();
    return rb.containsKey(key) ? (T) rb.getObject(key) : null;
}
 
Example 18
Source File: DateTimeTextProvider.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the localized resource of the given key and locale, or null
 * if no localized resource is available.
 *
 * @param key  the key of the localized resource, not null
 * @param locale  the locale, not null
 * @return the localized resource, or null if not available
 * @throws NullPointerException if key or locale is null
 */
@SuppressWarnings("unchecked")
static <T> T getLocalizedResource(String key, Locale locale) {
    LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                                .getLocaleResources(locale);
    ResourceBundle rb = lr.getJavaTimeFormatData();
    return rb.containsKey(key) ? (T) rb.getObject(key) : null;
}
 
Example 19
Source File: DateTimeTextProvider.java    From Java8CN with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the localized resource of the given key and locale, or null
 * if no localized resource is available.
 *
 * @param key  the key of the localized resource, not null
 * @param locale  the locale, not null
 * @return the localized resource, or null if not available
 * @throws NullPointerException if key or locale is null
 */
@SuppressWarnings("unchecked")
static <T> T getLocalizedResource(String key, Locale locale) {
    LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                                .getLocaleResources(locale);
    ResourceBundle rb = lr.getJavaTimeFormatData();
    return rb.containsKey(key) ? (T) rb.getObject(key) : null;
}
 
Example 20
Source File: DateTimeTextProvider.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the localized resource of the given key and locale, or null
 * if no localized resource is available.
 *
 * @param key  the key of the localized resource, not null
 * @param locale  the locale, not null
 * @return the localized resource, or null if not available
 * @throws NullPointerException if key or locale is null
 */
@SuppressWarnings("unchecked")
static <T> T getLocalizedResource(String key, Locale locale) {
    LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                                .getLocaleResources(locale);
    ResourceBundle rb = lr.getJavaTimeFormatData();
    return rb.containsKey(key) ? (T) rb.getObject(key) : null;
}