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


Java DateTimeFieldType.era方法代码示例

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


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

示例1: set

import org.joda.time.DateTimeFieldType; //导入方法依赖的package包/类
/** @inheritDoc */
public long set(long instant, String text, Locale locale) {
    if (iEraText.equals(text) == false && "1".equals(text) == false) {
        throw new IllegalFieldValueException(DateTimeFieldType.era(), text);
    }
    return instant;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:8,代码来源:BasicSingleEraDateTimeField.java

示例2: eraTextToValue

import org.joda.time.DateTimeFieldType; //导入方法依赖的package包/类
public int eraTextToValue(String text) {
    Integer era = iParseEras.get(text);
    if (era != null) {
        return era.intValue();
    }
    throw new IllegalFieldValueException(DateTimeFieldType.era(), text);
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:8,代码来源:GJLocaleSymbols.java

示例3: parseInto

import org.joda.time.DateTimeFieldType; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public int parseInto(DateTimeParserBucket bucket, String text, int position) {
    Locale locale = bucket.getLocale();
    // handle languages which might have non ASCII A-Z or punctuation
    // bug 1788282
    Set<String> validValues = null;
    int maxLength = 0;
    synchronized (cParseCache) {
        Map<DateTimeFieldType, Object[]> innerMap = cParseCache.get(locale);
        if (innerMap == null) {
            innerMap = new HashMap<DateTimeFieldType, Object[]>();
            cParseCache.put(locale, innerMap);
        }
        Object[] array = innerMap.get(iFieldType);
        if (array == null) {
            validValues = new HashSet<String>(32);
            MutableDateTime dt = new MutableDateTime(0L, DateTimeZone.UTC);
            Property property = dt.property(iFieldType);
            int min = property.getMinimumValueOverall();
            int max = property.getMaximumValueOverall();
            if (max - min > 32) {  // protect against invalid fields
                return ~position;
            }
            maxLength = property.getMaximumTextLength(locale);
            for (int i = min; i <= max; i++) {
                property.set(i);
                validValues.add(property.getAsShortText(locale));
                validValues.add(property.getAsShortText(locale).toLowerCase(locale));
                validValues.add(property.getAsShortText(locale).toUpperCase(locale));
                validValues.add(property.getAsText(locale));
                validValues.add(property.getAsText(locale).toLowerCase(locale));
                validValues.add(property.getAsText(locale).toUpperCase(locale));
            }
            if ("en".equals(locale.getLanguage()) && iFieldType == DateTimeFieldType.era()) {
                // hack to support for parsing "BCE" and "CE" if the language is English
                validValues.add("BCE");
                validValues.add("bce");
                validValues.add("CE");
                validValues.add("ce");
                maxLength = 3;
            }
            array = new Object[] {validValues, Integer.valueOf(maxLength)};
            innerMap.put(iFieldType, array);
        } else {
            validValues = (Set<String>) array[0];
            maxLength = ((Integer) array[1]).intValue();
        }
    }
    // match the longest string first using our knowledge of the max length
    int limit = Math.min(text.length(), position + maxLength);
    for (int i = limit; i > position; i--) {
        String match = text.substring(position, i);
        if (validValues.contains(match)) {
            bucket.saveField(iFieldType, match, locale);
            return i;
        }
    }
    return ~position;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:60,代码来源:DateTimeFormatterBuilder.java

示例4: BasicSingleEraDateTimeField

import org.joda.time.DateTimeFieldType; //导入方法依赖的package包/类
/**
 * Restricted constructor.
 */
BasicSingleEraDateTimeField(String text) {
    super(DateTimeFieldType.era());
    iEraText = text;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:8,代码来源:BasicSingleEraDateTimeField.java

示例5: GJEraDateTimeField

import org.joda.time.DateTimeFieldType; //导入方法依赖的package包/类
/**
 * Restricted constructor
 */
GJEraDateTimeField(BasicChronology chronology) {
    super(DateTimeFieldType.era());
    iChronology = chronology;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:8,代码来源:GJEraDateTimeField.java


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