当前位置: 首页>>代码示例>>Java>>正文


Java LocaleData.getDateFormatData方法代码示例

本文整理汇总了Java中sun.util.resources.LocaleData.getDateFormatData方法的典型用法代码示例。如果您正苦于以下问题:Java LocaleData.getDateFormatData方法的具体用法?Java LocaleData.getDateFormatData怎么用?Java LocaleData.getDateFormatData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.util.resources.LocaleData的用法示例。


在下文中一共展示了LocaleData.getDateFormatData方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cacheLookup

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
/**
 * Look up resource data for the desiredLocale in the cache; update the
 * cache if necessary.
 */
private static ResourceBundle cacheLookup(Locale desiredLocale) {
ResourceBundle rb;
SoftReference data
    = (SoftReference)cachedLocaleData.get(desiredLocale);
if (data == null) {
    rb = LocaleData.getDateFormatData(desiredLocale);
    data = new SoftReference(rb);
    cachedLocaleData.put(desiredLocale, data);
} else {
    if ((rb = (ResourceBundle)data.get()) == null) {
    rb = LocaleData.getDateFormatData(desiredLocale);
    data = new SoftReference(rb);
    }
}
return rb;
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:21,代码来源:DateFormatSymbols.java

示例2: initializeData

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
private void initializeData(Locale desiredLocale) {
    locale = desiredLocale;

    // Copy values of a cached instance if any.
    SoftReference<DateFormatSymbols> ref = cachedInstances.get(locale);
    DateFormatSymbols dfs;
    if (ref != null && (dfs = ref.get()) != null) {
        copyMembers(dfs, this);
        return;
    }

    // Initialize the fields from the ResourceBundle for locale.
    ResourceBundle resource = LocaleData.getDateFormatData(locale);

    eras = resource.getStringArray("Eras");
    months = resource.getStringArray("MonthNames");
    shortMonths = resource.getStringArray("MonthAbbreviations");
    ampms = resource.getStringArray("AmPmMarkers");
    localPatternChars = resource.getString("DateTimePatternChars");

    // Day of week names are stored in a 1-based array.
    weekdays = toOneBasedArray(resource.getStringArray("DayNames"));
    shortWeekdays = toOneBasedArray(resource.getStringArray("DayAbbreviations"));
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:25,代码来源:DateFormatSymbols.java

示例3: getDisplayName

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
public String getDisplayName(int field, int style, Locale locale) {
    if (field != ERA) {
        return super.getDisplayName(field, style, locale);
    }

    // Handle Thai BuddhistCalendar specific era names
    if (field < 0 || field >= fields.length ||
        style < SHORT || style > LONG) {
        throw new IllegalArgumentException();
    }
    if (locale == null) {
        throw new NullPointerException();
    }
    ResourceBundle rb = LocaleData.getDateFormatData(locale);
    String[] eras = rb.getStringArray(getKey(style));
    return eras[get(field)];
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:18,代码来源:BuddhistCalendar.java

示例4: getDisplayName

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
public String getDisplayName(int field, int style, Locale locale) {
if (!checkDisplayNameParams(field, style, SHORT, LONG, locale,
			    ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) {
    return null;
}

// "GanNen" is supported only in the LONG style.
if (field == YEAR
    && (style == SHORT || get(YEAR) != 1 || get(ERA) == 0)) {
    return null;
}

ResourceBundle rb = LocaleData.getDateFormatData(locale);
String name = null;
String key = getKey(field, style);
if (key != null) {
    String[] strings = rb.getStringArray(key);
    if (field == YEAR) {
	if (strings.length > 0) {
	    name = strings[0];
	}
    } else {
	int index = get(field);
	// If the ERA value is out of range for strings, then
	// try to get its name or abbreviation from the Era instance.
	if (field == ERA && index >= strings.length && index < eras.length) {
	    Era era = eras[index];
	    name = (style == SHORT) ? era.getAbbreviation() : era.getName();
	} else {
	    if (field == DAY_OF_WEEK)
		--index;
	    name = strings[index];
	}
    }
}
return name;
   }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:38,代码来源:JapaneseImperialCalendar.java

示例5: getDisplayNamesImpl

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
private Map<String,Integer> getDisplayNamesImpl(int field, int style, Locale locale) {
ResourceBundle rb = LocaleData.getDateFormatData(locale);
String key = getKey(field, style);
Map<String,Integer> map = new HashMap<String,Integer>();
if (key != null) {
    String[] strings = rb.getStringArray(key);
    if (field == YEAR) {
	if (strings.length > 0) {
	    map.put(strings[0], 1);
	}
    } else {
	int base = (field == DAY_OF_WEEK) ? 1 : 0;
	for (int i = 0; i < strings.length; i++) {
	    map.put(strings[i], base + i);
	}
	// If strings[] has fewer than eras[], get more names from eras[].
	if (field == ERA && strings.length < eras.length) {
	    for (int i = strings.length; i < eras.length; i++) {
		Era era = eras[i];
		String name = (style == SHORT) ? era.getAbbreviation() : era.getName();
		map.put(name, i);
	    }
	}
    }
}
return map.size() > 0 ? map : null;
   }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:28,代码来源:JapaneseImperialCalendar.java

示例6: getDisplayName

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
public String getDisplayName(int field, int style, Locale locale) {
    if (!checkDisplayNameParams(field, style, SHORT, LONG, locale,
                                ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) {
        return null;
    }

    // "GanNen" is supported only in the LONG style.
    if (field == YEAR
        && (style == SHORT || get(YEAR) != 1 || get(ERA) == 0)) {
        return null;
    }

    ResourceBundle rb = LocaleData.getDateFormatData(locale);
    String name = null;
    String key = getKey(field, style);
    if (key != null) {
        String[] strings = rb.getStringArray(key);
        if (field == YEAR) {
            if (strings.length > 0) {
                name = strings[0];
            }
        } else {
            int index = get(field);
            // If the ERA value is out of range for strings, then
            // try to get its name or abbreviation from the Era instance.
            if (field == ERA && index >= strings.length && index < eras.length) {
                Era era = eras[index];
                name = (style == SHORT) ? era.getAbbreviation() : era.getName();
            } else {
                if (field == DAY_OF_WEEK)
                    --index;
                name = strings[index];
            }
        }
    }
    return name;
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:38,代码来源:JapaneseImperialCalendar.java

示例7: getDisplayNamesImpl

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
private Map<String,Integer> getDisplayNamesImpl(int field, int style, Locale locale) {
    ResourceBundle rb = LocaleData.getDateFormatData(locale);
    String key = getKey(field, style);
    Map<String,Integer> map = new HashMap<String,Integer>();
    if (key != null) {
        String[] strings = rb.getStringArray(key);
        if (field == YEAR) {
            if (strings.length > 0) {
                map.put(strings[0], 1);
            }
        } else {
            int base = (field == DAY_OF_WEEK) ? 1 : 0;
            for (int i = 0; i < strings.length; i++) {
                map.put(strings[i], base + i);
            }
            // If strings[] has fewer than eras[], get more names from eras[].
            if (field == ERA && strings.length < eras.length) {
                for (int i = strings.length; i < eras.length; i++) {
                    Era era = eras[i];
                    String name = (style == SHORT) ? era.getAbbreviation() : era.getName();
                    map.put(name, i);
                }
            }
        }
    }
    return map.size() > 0 ? map : null;
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:28,代码来源:JapaneseImperialCalendar.java

示例8: getDefaultPattern

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
private static String getDefaultPattern(Locale loc) {
    ResourceBundle r = LocaleData.getDateFormatData(loc);
    String[] dateTimePatterns = r.getStringArray("DateTimePatterns");
    Object[] dateTimeArgs = {dateTimePatterns[DateFormat.SHORT],
                             dateTimePatterns[DateFormat.SHORT + 4]};
    return MessageFormat.format(dateTimePatterns[8], dateTimeArgs);
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:8,代码来源:JSpinner.java

示例9: getDisplayNamesImpl

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
private Map<String,Integer> getDisplayNamesImpl(int field, int style, Locale locale) {
    ResourceBundle rb = LocaleData.getDateFormatData(locale);
    String[] eras = rb.getStringArray(getKey(style));
    Map<String,Integer> map = new HashMap<String,Integer>(4);
    for (int i = 0; i < eras.length; i++) {
        map.put(eras[i], i);
    }
    return map;
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:10,代码来源:BuddhistCalendar.java

示例10: SimpleDateFormat

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
SimpleDateFormat(int timeStyle, int dateStyle, Locale loc) {
if (loc == null) {
    throw new NullPointerException();
}

this.locale = loc;
// initialize calendar and related fields
initializeCalendar(loc);

       /* try the cache first */
String key = getKey();
       String[] dateTimePatterns = cachedLocaleData.get(key);
       if (dateTimePatterns == null) { /* cache miss */
           ResourceBundle r = LocaleData.getDateFormatData(loc);
    if (!isGregorianCalendar()) {
	try {
	    dateTimePatterns = r.getStringArray(getCalendarName() + ".DateTimePatterns");
	} catch (MissingResourceException e) {
	}
    }
    if (dateTimePatterns == null) {
	dateTimePatterns = r.getStringArray("DateTimePatterns");
    }
           /* update cache */
           cachedLocaleData.put(key, dateTimePatterns);
       }
formatData = DateFormatSymbols.getInstance(loc);
if ((timeStyle >= 0) && (dateStyle >= 0)) {
    Object[] dateTimeArgs = {dateTimePatterns[timeStyle],
			     dateTimePatterns[dateStyle + 4]};
    pattern = MessageFormat.format(dateTimePatterns[8], dateTimeArgs);
}
else if (timeStyle >= 0) {
    pattern = dateTimePatterns[timeStyle];
}
else if (dateStyle >= 0) {
           pattern = dateTimePatterns[dateStyle + 4];
}
else {
    throw new IllegalArgumentException("No date or time style specified");
}

initialize(loc);
   }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:45,代码来源:SimpleDateFormat.java

示例11: SimpleDateFormat

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
SimpleDateFormat(int timeStyle, int dateStyle, Locale loc) {
    if (loc == null) {
        throw new NullPointerException();
    }

    this.locale = loc;
    // initialize calendar and related fields
    initializeCalendar(loc);

    /* try the cache first */
    String[] dateTimePatterns = cachedLocaleData.get(loc);
    if (dateTimePatterns == null) { /* cache miss */
        ResourceBundle r = LocaleData.getDateFormatData(loc);
        if (!isGregorianCalendar()) {
            try {
                dateTimePatterns = r.getStringArray(getCalendarName() + ".DateTimePatterns");
            } catch (MissingResourceException e) {
            }
        }
        if (dateTimePatterns == null) {
            dateTimePatterns = r.getStringArray("DateTimePatterns");
        }
        /* update cache */
        cachedLocaleData.putIfAbsent(loc, dateTimePatterns);
    }
    formatData = DateFormatSymbols.getInstanceRef(loc);
    if ((timeStyle >= 0) && (dateStyle >= 0)) {
        Object[] dateTimeArgs = {dateTimePatterns[timeStyle],
                                 dateTimePatterns[dateStyle + 4]};
        pattern = MessageFormat.format(dateTimePatterns[8], dateTimeArgs);
    }
    else if (timeStyle >= 0) {
        pattern = dateTimePatterns[timeStyle];
    }
    else if (dateStyle >= 0) {
        pattern = dateTimePatterns[dateStyle + 4];
    }
    else {
        throw new IllegalArgumentException("No date or time style specified");
    }

    initialize(loc);
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:44,代码来源:SimpleDateFormat.java

示例12: FormatData_zh_HK

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
public FormatData_zh_HK() {
    ResourceBundle bundle = LocaleData.getDateFormatData(Locale.TAIWAN);
    setParent(bundle);
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:5,代码来源:FormatData_zh_HK.java


注:本文中的sun.util.resources.LocaleData.getDateFormatData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。