本文整理汇总了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;
}
示例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;
}
}
示例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;
}
示例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;
}