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


Java Calendar.AM_PM属性代码示例

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


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

示例1: getPatterns

/**
 * @internal
 * @deprecated This API is ICU internal only.
 */
@Deprecated
public String getPatterns(Calendar fromCalendar,
        Calendar toCalendar, 
        Output<String> part2) {
    // First, find the largest different calendar field.
    int field;
    if ( fromCalendar.get(Calendar.ERA) != toCalendar.get(Calendar.ERA) ) {
        field = Calendar.ERA;
    } else if ( fromCalendar.get(Calendar.YEAR) != 
                toCalendar.get(Calendar.YEAR) ) {
        field = Calendar.YEAR;
    } else if ( fromCalendar.get(Calendar.MONTH) !=
                toCalendar.get(Calendar.MONTH) ) {
        field = Calendar.MONTH;
    } else if ( fromCalendar.get(Calendar.DATE) !=
                toCalendar.get(Calendar.DATE) ) {
        field = Calendar.DATE;
    } else if ( fromCalendar.get(Calendar.AM_PM) !=
                toCalendar.get(Calendar.AM_PM) ) {
        field = Calendar.AM_PM;
    } else if ( fromCalendar.get(Calendar.HOUR) !=
                toCalendar.get(Calendar.HOUR) ) {
        field = Calendar.HOUR;
    } else if ( fromCalendar.get(Calendar.MINUTE) !=
                toCalendar.get(Calendar.MINUTE) ) {
        field = Calendar.MINUTE;
    } else if ( fromCalendar.get(Calendar.SECOND) !=
                toCalendar.get(Calendar.SECOND) ) {
        field = Calendar.SECOND;
    } else {
        return null;
    }
    PatternInfo intervalPattern = fIntervalPatterns.get(
            DateIntervalInfo.CALENDAR_FIELD_TO_PATTERN_LETTER[field]);
    part2.value = intervalPattern.getSecondPart();
    return intervalPattern.getFirstPart();
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:41,代码来源:DateIntervalFormat.java

示例2: genIntervalPattern

private SkeletonAndItsBestMatch genIntervalPattern(
               int field, String skeleton, String bestSkeleton, 
               int differenceInfo, Map<String, PatternInfo> intervalPatterns) {
    SkeletonAndItsBestMatch retValue = null;
    PatternInfo pattern = fInfo.getIntervalPattern(
                                       bestSkeleton, field);
    if ( pattern == null ) {
        // single date
        if ( SimpleDateFormat.isFieldUnitIgnored(bestSkeleton, field) ) {
            PatternInfo ptnInfo = 
                new PatternInfo(fDateFormat.toPattern(),
                                                 null, 
                                                 fInfo.getDefaultOrder());
            intervalPatterns.put(DateIntervalInfo.
                CALENDAR_FIELD_TO_PATTERN_LETTER[field], ptnInfo);
            return null;
        }

        // for 24 hour system, interval patterns in resource file
        // might not include pattern when am_pm differ, 
        // which should be the same as hour differ.
        // add it here for simplicity
        if ( field == Calendar.AM_PM ) {
             pattern = fInfo.getIntervalPattern(bestSkeleton, 
                                                     Calendar.HOUR);
             if ( pattern != null ) {
                  // share
                  intervalPatterns.put(DateIntervalInfo.
                      CALENDAR_FIELD_TO_PATTERN_LETTER[field], 
                      pattern);
             }
             return null;
        } 
        // else, looking for pattern when 'y' differ for 'dMMMM' skeleton,
        // first, get best match pattern "MMMd",
        // since there is no pattern for 'y' differs for skeleton 'MMMd',
        // need to look for it from skeleton 'yMMMd',
        // if found, adjust field width in interval pattern from
        // "MMM" to "MMMM".
        String fieldLetter = 
            DateIntervalInfo.CALENDAR_FIELD_TO_PATTERN_LETTER[field];
        bestSkeleton = fieldLetter + bestSkeleton;
        skeleton = fieldLetter + skeleton;
        // for example, looking for patterns when 'y' differ for
        // skeleton "MMMM".
        pattern = fInfo.getIntervalPattern(bestSkeleton, field);
        if ( pattern == null && differenceInfo == 0 ) {
            // if there is no skeleton "yMMMM" defined,
            // look for the best match skeleton, for example: "yMMM"
            BestMatchInfo tmpRetValue = fInfo.getBestSkeleton(skeleton);
            String tmpBestSkeleton = tmpRetValue.bestMatchSkeleton;
            differenceInfo =  tmpRetValue.bestMatchDistanceInfo;
            if ( tmpBestSkeleton.length() != 0 && differenceInfo != -1 ) {
                pattern = fInfo.getIntervalPattern(tmpBestSkeleton, field);
                bestSkeleton = tmpBestSkeleton;
            }
        }
        if ( pattern != null ) {
            retValue = new SkeletonAndItsBestMatch(skeleton, bestSkeleton);
        }
    } 
    if ( pattern != null ) {
        if ( differenceInfo != 0 ) {
            String part1 = adjustFieldWidth(skeleton, bestSkeleton, 
                               pattern.getFirstPart(), differenceInfo);
            String part2 = adjustFieldWidth(skeleton, bestSkeleton, 
                               pattern.getSecondPart(), differenceInfo);
            pattern =  new PatternInfo(part1, part2, 
                                       pattern.firstDateInPtnIsLaterDate());
        } else {
            // pattern is immutable, no need to clone; 
            // pattern = (PatternInfo)pattern.clone();
        }
        intervalPatterns.put(
          DateIntervalInfo.CALENDAR_FIELD_TO_PATTERN_LETTER[field], pattern);
    }
    return retValue;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:78,代码来源:DateIntervalFormat.java


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