org.joda.time.Seconds.seconds()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中org.joda.time.Seconds.seconds()方法的一些代码示例,展示了Seconds.seconds()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Seconds.seconds()方法的具体详情如下:
包路径:org.joda.time.Seconds
类名称:Seconds
方法名:seconds

Seconds.seconds介绍

[英]Obtains an instance of Seconds that may be cached. Seconds is immutable, so instances can be cached and shared. This factory method provides access to shared instances.
[中]获取可缓存的Seconds实例。Seconds是不可变的,因此可以缓存和共享实例。此工厂方法提供对共享实例的访问。

代码示例

代码示例来源:origin: joda-time/joda-time

/**
 * Resolves singletons.
 * 
 * @return the singleton instance
 */
private Object readResolve() {
  return Seconds.seconds(getValue());
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Resolves singletons.
 * 
 * @return the singleton instance
 */
private Object readResolve() {
  return Seconds.seconds(getValue());
}

代码示例来源:origin: joda-time/joda-time

/**
 * Returns a new instance with the seconds divided by the specified divisor.
 * The calculation uses integer division, thus 3 divided by 2 is 1.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param divisor  the amount to divide by, may be negative
 * @return the new period divided by the specified divisor
 * @throws ArithmeticException if the divisor is zero
 */
public Seconds dividedBy(int divisor) {
  if (divisor == 1) {
    return this;
  }
  return Seconds.seconds(getValue() / divisor);
}

代码示例来源:origin: joda-time/joda-time

/**
 * Returns a new instance with the seconds multiplied by the specified scalar.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param scalar  the amount to multiply by, may be negative
 * @return the new period multiplied by the specified scalar
 * @throws ArithmeticException if the result overflows an int
 */
public Seconds multipliedBy(int scalar) {
  return Seconds.seconds(FieldUtils.safeMultiply(getValue(), scalar));
}

代码示例来源:origin: joda-time/joda-time

/**
 * Returns a new instance with the seconds value negated.
 *
 * @return the new period with a negated value
 * @throws ArithmeticException if the result overflows an int
 */
public Seconds negated() {
  return Seconds.seconds(FieldUtils.safeNegate(getValue()));
}

代码示例来源:origin: joda-time/joda-time

/**
 * Creates a <code>Seconds</code> representing the number of whole seconds
 * between the two specified datetimes.
 *
 * @param start  the start instant, must not be null
 * @param end  the end instant, must not be null
 * @return the period in seconds
 * @throws IllegalArgumentException if the instants are null or invalid
 */
public static Seconds secondsBetween(ReadableInstant start, ReadableInstant end) {
  int amount = BaseSingleFieldPeriod.between(start, end, DurationFieldType.seconds());
  return Seconds.seconds(amount);
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Returns a new instance with the seconds multiplied by the specified scalar.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param scalar  the amount to multiply by, may be negative
 * @return the new period multiplied by the specified scalar
 * @throws ArithmeticException if the result overflows an int
 */
public Seconds multipliedBy(int scalar) {
  return Seconds.seconds(FieldUtils.safeMultiply(getValue(), scalar));
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Returns a new instance with the seconds value negated.
 *
 * @return the new period with a negated value
 * @throws ArithmeticException if the result overflows an int
 */
public Seconds negated() {
  return Seconds.seconds(FieldUtils.safeNegate(getValue()));
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Creates a <code>Seconds</code> representing the number of whole seconds
 * between the two specified datetimes.
 *
 * @param start  the start instant, must not be null
 * @param end  the end instant, must not be null
 * @return the period in seconds
 * @throws IllegalArgumentException if the instants are null or invalid
 */
public static Seconds secondsBetween(ReadableInstant start, ReadableInstant end) {
  int amount = BaseSingleFieldPeriod.between(start, end, DurationFieldType.seconds());
  return Seconds.seconds(amount);
}

代码示例来源:origin: joda-time/joda-time

/**
 * Converts this duration to a period in seconds assuming that there are the
 * standard number of milliseconds in a second.
 * <p>
 * This method assumes that there are 1000 milliseconds in a second.
 * All currently supplied chronologies use this definition.
 * 
 * @return a period representing the number of standard seconds in this period, never null
 * @throws ArithmeticException if the number of seconds is too large to be represented
 * @since 1.6
 */
public Seconds toStandardSeconds() {
  long seconds = getStandardSeconds();
  return Seconds.seconds(FieldUtils.safeToInt(seconds));
}

代码示例来源:origin: joda-time/joda-time

/**
 * Returns a new instance with the specified number of seconds added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param seconds  the amount of seconds to add, may be negative
 * @return the new period plus the specified number of seconds
 * @throws ArithmeticException if the result overflows an int
 */
public Seconds plus(int seconds) {
  if (seconds == 0) {
    return this;
  }
  return Seconds.seconds(FieldUtils.safeAdd(getValue(), seconds));
}

代码示例来源:origin: joda-time/joda-time

/**
 * Converts this period in minutes to a period in seconds assuming a
 * 60 second minute.
 * <p>
 * This method allows you to convert between different types of period.
 * However to achieve this it makes the assumption that all minutes are
 * 60 seconds long.
 * This may not be true for some unusual chronologies. However, it is included
 * as it is a useful operation for many applications and business rules.
 * 
 * @return a period representing the number of seconds for this number of minutes
 * @throws ArithmeticException if the number of seconds is too large to be represented
 */
public Seconds toStandardSeconds() {
  return Seconds.seconds(FieldUtils.safeMultiply(getValue(), DateTimeConstants.SECONDS_PER_MINUTE));
}

代码示例来源:origin: joda-time/joda-time

/**
 * Converts this period in hours to a period in seconds assuming a
 * 60 minute hour and 60 second minute.
 * <p>
 * This method allows you to convert between different types of period.
 * However to achieve this it makes the assumption that all hours are
 * 60 minutes long and all minutes are 60 seconds long.
 * This may not be true for some unusual chronologies. However, it is included
 * as it is a useful operation for many applications and business rules.
 * 
 * @return a period representing the number of seconds for this number of hours
 * @throws ArithmeticException if the number of seconds is too large to be represented
 */
public Seconds toStandardSeconds() {
  return Seconds.seconds(FieldUtils.safeMultiply(getValue(), DateTimeConstants.SECONDS_PER_HOUR));
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Returns a new instance with the specified number of seconds added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param seconds  the amount of seconds to add, may be negative
 * @return the new period plus the specified number of seconds
 * @throws ArithmeticException if the result overflows an int
 */
public Seconds plus(int seconds) {
  if (seconds == 0) {
    return this;
  }
  return Seconds.seconds(FieldUtils.safeAdd(getValue(), seconds));
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Converts this duration to a period in seconds assuming that there are the
 * standard number of milliseconds in a second.
 * <p>
 * This method assumes that there are 1000 milliseconds in a second.
 * All currently supplied chronologies use this definition.
 * 
 * @return a period representing the number of standard seconds in this period, never null
 * @throws ArithmeticException if the number of seconds is too large to be represented
 * @since 1.6
 */
public Seconds toStandardSeconds() {
  long seconds = getStandardSeconds();
  return Seconds.seconds(FieldUtils.safeToInt(seconds));
}

代码示例来源:origin: joda-time/joda-time

/**
 * Converts this period in days to a period in seconds assuming a
 * 24 hour day, 60 minute hour and 60 second minute.
 * <p>
 * This method allows you to convert between different types of period.
 * However to achieve this it makes the assumption that all days are 24 hours
 * long, all hours are 60 minutes long and all minutes are 60 seconds long.
 * This is not true when daylight savings is considered and may also not
 * be true for some unusual chronologies. However, it is included
 * as it is a useful operation for many applications and business rules.
 * 
 * @return a period representing the number of seconds for this number of days
 * @throws ArithmeticException if the number of seconds is too large to be represented
 */
public Seconds toStandardSeconds() {
  return Seconds.seconds(FieldUtils.safeMultiply(getValue(), DateTimeConstants.SECONDS_PER_DAY));
}

代码示例来源:origin: Graylog2/graylog2-server

@Override
@JsonIgnore
public DateTime getFrom() {
  // TODO this should be computed once
  if (range() > 0) {
    return Tools.nowUTC().minus(Seconds.seconds(range()));
  }
  return new DateTime(0, DateTimeZone.UTC);
}

代码示例来源:origin: joda-time/joda-time

/**
 * Converts this period in weeks to a period in seconds assuming a
 * 7 day week, 24 hour day, 60 minute hour and 60 second minute.
 * <p>
 * This method allows you to convert between different types of period.
 * However to achieve this it makes the assumption that all weeks are
 * 7 days long, all days are 24 hours long, all hours are 60 minutes long
 * and all minutes are 60 seconds long.
 * This is not true when daylight savings is considered and may also not
 * be true for some unusual chronologies. However, it is included
 * as it is a useful operation for many applications and business rules.
 * 
 * @return a period representing the number of seconds for this number of weeks
 * @throws ArithmeticException if the number of seconds is too large to be represented
 */
public Seconds toStandardSeconds() {
  return Seconds.seconds(FieldUtils.safeMultiply(getValue(), DateTimeConstants.SECONDS_PER_WEEK));
}

代码示例来源:origin: joda-time/joda-time

/**
 * Creates a <code>Seconds</code> representing the number of whole seconds
 * in the specified interval.
 *
 * @param interval  the interval to extract seconds from, null returns zero
 * @return the period in seconds
 * @throws IllegalArgumentException if the partials are null or invalid
 */
public static Seconds secondsIn(ReadableInterval interval) {
  if (interval == null)   {
    return Seconds.ZERO;
  }
  int amount = BaseSingleFieldPeriod.between(interval.getStart(), interval.getEnd(), DurationFieldType.seconds());
  return Seconds.seconds(amount);
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Creates a <code>Seconds</code> representing the number of whole seconds
 * in the specified interval.
 *
 * @param interval  the interval to extract seconds from, null returns zero
 * @return the period in seconds
 * @throws IllegalArgumentException if the partials are null or invalid
 */
public static Seconds secondsIn(ReadableInterval interval) {
  if (interval == null)   {
    return Seconds.ZERO;
  }
  int amount = BaseSingleFieldPeriod.between(interval.getStart(), interval.getEnd(), DurationFieldType.seconds());
  return Seconds.seconds(amount);
}

相关文章