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


Java Calendar.HOUR_OF_DAY属性代码示例

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


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

示例1: setIntervalPattern

/**
 * Provides a way for client to build interval patterns.
 * User could construct DateIntervalInfo by providing
 * a list of skeletons and their patterns.
 * <P>
 * For example:
 * <pre>
 * DateIntervalInfo dIntervalInfo = new DateIntervalInfo();
 * dIntervalInfo.setIntervalPattern("yMd", Calendar.YEAR, "'from' yyyy-M-d 'to' yyyy-M-d");
 * dIntervalInfo.setIntervalPattern("yMMMd", Calendar.MONTH, "'from' yyyy MMM d 'to' MMM d");
 * dIntervalInfo.setIntervalPattern("yMMMd", Calendar.DAY, "yyyy MMM d-d");
 * dIntervalInfo.setFallbackIntervalPattern("{0} ~ {1}");
 * </pre>
 *
 * Restriction:
 * Currently, users can only set interval patterns when the following
 * calendar fields are different: ERA, YEAR, MONTH, DATE,  DAY_OF_MONTH,
 * DAY_OF_WEEK, AM_PM,  HOUR, HOUR_OF_DAY, MINUTE, and SECOND.
 * Interval patterns when other calendar fields are different are
 * not supported.
 *
 * @param skeleton         the skeleton on which interval pattern based
 * @param lrgDiffCalUnit   the largest different calendar unit.
 * @param intervalPattern  the interval pattern on the largest different
 *                         calendar unit.
 *                         For example, if lrgDiffCalUnit is
 *                         "year", the interval pattern for en_US when year
 *                         is different could be "'from' yyyy 'to' yyyy".
 * @throws IllegalArgumentException  if setting interval pattern on
 *                            a calendar field that is smaller
 *                            than the MINIMUM_SUPPORTED_CALENDAR_FIELD
 * @throws UnsupportedOperationException  if the object is frozen
 * @stable ICU 4.0
 */
public void setIntervalPattern(String skeleton,
                               int lrgDiffCalUnit,
                               String intervalPattern)
{
    if ( frozen ) {
        throw new UnsupportedOperationException("no modification is allowed after DII is frozen");
    }
    if ( lrgDiffCalUnit > MINIMUM_SUPPORTED_CALENDAR_FIELD ) {
        throw new IllegalArgumentException("calendar field is larger than MINIMUM_SUPPORTED_CALENDAR_FIELD");
    }
    if (fIntervalPatternsReadOnly) {
        fIntervalPatterns = cloneIntervalPatterns(fIntervalPatterns);
        fIntervalPatternsReadOnly = false;
    }
    PatternInfo ptnInfo = setIntervalPatternInternally(skeleton,
                      CALENDAR_FIELD_TO_PATTERN_LETTER[lrgDiffCalUnit],
                      intervalPattern);
    if ( lrgDiffCalUnit == Calendar.HOUR_OF_DAY ) {
        setIntervalPattern(skeleton,
                           CALENDAR_FIELD_TO_PATTERN_LETTER[Calendar.AM_PM],
                           ptnInfo);
        setIntervalPattern(skeleton,
                           CALENDAR_FIELD_TO_PATTERN_LETTER[Calendar.HOUR],
                           ptnInfo);
    } else if ( lrgDiffCalUnit == Calendar.DAY_OF_MONTH ||
                lrgDiffCalUnit == Calendar.DAY_OF_WEEK ) {
        setIntervalPattern(skeleton,
                           CALENDAR_FIELD_TO_PATTERN_LETTER[Calendar.DATE],
                           ptnInfo);
    }
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:65,代码来源:DateIntervalInfo.java


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