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


Java DurationField.getUnitMillis方法代码示例

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


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

示例1: PreciseDateTimeField

import org.joda.time.DurationField; //导入方法依赖的package包/类
/**
 * Constructor.
 * 
 * @param type  the field type this field uses
 * @param unit  precise unit duration, like "seconds()".
 * @param range precise range duration, preferably a multiple of the unit,
 * like "minutes()".
 * @throws IllegalArgumentException if either duration field is imprecise
 * @throws IllegalArgumentException if unit milliseconds is less than one
 * or effective value range is less than two.
 */
public PreciseDateTimeField(DateTimeFieldType type,
                            DurationField unit, DurationField range) {
    super(type, unit);

    if (!range.isPrecise()) {
        throw new IllegalArgumentException("Range duration field must be precise");
    }

    long rangeMillis = range.getUnitMillis();
    iRange = (int)(rangeMillis / getUnitMillis());
    if (iRange < 2) {
        throw new IllegalArgumentException("The effective range must be at least 2");
    }

    iRangeField = range;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:28,代码来源:PreciseDateTimeField.java

示例2: compareTo

import org.joda.time.DurationField; //导入方法依赖的package包/类
public int compareTo(DurationField otherField) {
    long otherMillis = otherField.getUnitMillis();
    long thisMillis = getUnitMillis();
    // cannot do (thisMillis - otherMillis) as can overflow
    if (thisMillis == otherMillis) {
        return 0;
    }
    if (thisMillis < otherMillis) {
        return -1;
    } else {
        return 1;
    }
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:14,代码来源:MillisDurationField.java

示例3: PreciseDurationDateTimeField

import org.joda.time.DurationField; //导入方法依赖的package包/类
/**
 * Constructor.
 * 
 * @param type  the field type
 * @param unit  precise unit duration, like "days()".
 * @throws IllegalArgumentException if duration field is imprecise
 * @throws IllegalArgumentException if unit milliseconds is less than one
 */
public PreciseDurationDateTimeField(DateTimeFieldType type, DurationField unit) {
    super(type);

    if (!unit.isPrecise()) {
        throw new IllegalArgumentException("Unit duration field must be precise");
    }

    iUnitMillis = unit.getUnitMillis();
    if (iUnitMillis < 1) {
        throw new IllegalArgumentException("The unit milliseconds must be at least 1");
    }

    iUnitField = unit;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:23,代码来源:PreciseDurationDateTimeField.java

示例4: useTimeArithmetic

import org.joda.time.DurationField; //导入方法依赖的package包/类
static boolean useTimeArithmetic(DurationField field) {
    // Use time of day arithmetic rules for unit durations less than
    // typical time zone offsets.
    return field != null && field.getUnitMillis() < DateTimeConstants.MILLIS_PER_HOUR * 12;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:6,代码来源:ZonedChronology.java


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