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


Java ReadableDuration.getMillis方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:17,代码来源:TimeUtil.java

示例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;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:22,代码来源:AbstractDuration.java

示例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());
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:18,代码来源:AbstractDuration.java

示例4: toLong

import org.joda.time.ReadableDuration; //导入方法依赖的package包/类
private Long toLong(ReadableDuration value) {
  return value.getMillis();
}
 
开发者ID:apache,项目名称:beam,代码行数:4,代码来源:DurationCoder.java

示例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]);
    }
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:21,代码来源:ReadableDurationConverter.java

示例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));
}
 
开发者ID:Cook-E-team,项目名称:Cook-E,代码行数:11,代码来源:TimerFragment.java

示例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());
}
 
开发者ID:Cook-E-team,项目名称:Cook-E,代码行数:9,代码来源:TimerFragment.java


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