本文整理汇总了Java中org.joda.time.ReadableDuration.getMillis方法的典型用法代码示例。如果您正苦于以下问题:Java ReadableDuration.getMillis方法的具体用法?Java ReadableDuration.getMillis怎么用?Java ReadableDuration.getMillis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.ReadableDuration
的用法示例。
在下文中一共展示了ReadableDuration.getMillis方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toCloudDuration
import org.joda.time.ReadableDuration; //导入方法依赖的package包/类
/**
* Converts a {@link ReadableDuration} into a Dataflow API duration string.
*/
public static String toCloudDuration(ReadableDuration duration) {
// Note that since Joda objects use millisecond resolution, we always
// produce either no fractional seconds or fractional seconds with
// millisecond resolution.
long millis = duration.getMillis();
long seconds = millis / 1000;
millis = millis % 1000;
if (millis == 0) {
return String.format("%ds", seconds);
} else {
return String.format("%d.%03ds", seconds, millis);
}
}
示例2: compareTo
import org.joda.time.ReadableDuration; //导入方法依赖的package包/类
/**
* Compares this duration with the specified duration based on length.
*
* @param other a duration to check against
* @return negative value if this is less, 0 if equal, or positive value if greater
* @throws NullPointerException if the object is null
* @throws ClassCastException if the given object is not supported
*/
public int compareTo(ReadableDuration other) {
long thisMillis = this.getMillis();
long otherMillis = other.getMillis();
// cannot do (thisMillis - otherMillis) as it can overflow
if (thisMillis < otherMillis) {
return -1;
}
if (thisMillis > otherMillis) {
return 1;
}
return 0;
}
示例3: equals
import org.joda.time.ReadableDuration; //导入方法依赖的package包/类
/**
* Compares this object with the specified object for equality based
* on the millisecond length. All ReadableDuration instances are accepted.
*
* @param duration a readable duration to check against
* @return true if the length of the duration is equal
*/
public boolean equals(Object duration) {
if (this == duration) {
return true;
}
if (duration instanceof ReadableDuration == false) {
return false;
}
ReadableDuration other = (ReadableDuration) duration;
return (getMillis() == other.getMillis());
}
示例4: toLong
import org.joda.time.ReadableDuration; //导入方法依赖的package包/类
private Long toLong(ReadableDuration value) {
return value.getMillis();
}
示例5: setInto
import org.joda.time.ReadableDuration; //导入方法依赖的package包/类
/**
* Extracts duration values from an object of this converter's type, and
* sets them into the given ReadWritableDuration.
*
* @param writablePeriod period to get modified
* @param object the object to convert, must not be null
* @param chrono the chronology to use, must not be null
* @throws NullPointerException if the duration or object is null
* @throws ClassCastException if the object is an invalid type
* @throws IllegalArgumentException if the object is invalid
*/
public void setInto(ReadWritablePeriod writablePeriod, Object object, Chronology chrono) {
ReadableDuration dur = (ReadableDuration) object;
chrono = DateTimeUtils.getChronology(chrono);
long duration = dur.getMillis();
int[] values = chrono.get(writablePeriod, duration);
for (int i = 0; i < values.length; i++) {
writablePeriod.setValue(i, values[i]);
}
}
示例6: roundDownToSecond
import org.joda.time.ReadableDuration; //导入方法依赖的package包/类
/**
* Rounds a duration down to the nearest second
* @param duration the duration to round. Must not be null.
* @return a duration up to 1 second less than the provided duration, representing an
* integer number of seconds
*/
private static Duration roundDownToSecond(ReadableDuration duration) {
final long millis = duration.getMillis();
return Duration.millis(millis - (millis % 1000));
}
示例7: StepTimer
import org.joda.time.ReadableDuration; //导入方法依赖的package包/类
/**
* Creates a new StepTimer
*
* @param duration the duration to count for
*/
public StepTimer(ReadableDuration duration) {
super(duration.getMillis(), INTERVAL.getMillis());
}