java.time.Duration.minusSeconds()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(160)

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

Duration.minusSeconds介绍

[英]Returns a copy of this duration with the specified duration in seconds subtracted.

This instance is immutable and unaffected by this method call.
[中]返回此持续时间的副本,并减去指定的持续时间(以秒为单位)。
此实例是不可变的,不受此方法调用的影响。

代码示例

代码示例来源:origin: debezium/debezium

return Duration.ofHours(hours)
    .minusMinutes(minutes)
    .minusSeconds(seconds)
    .minusNanos(nanoSeconds);

代码示例来源:origin: org.codehaus.groovy/groovy-datetime

/**
 * Returns a {@link java.time.Duration} that is one second shorter than this duration.
 *
 * @param self a Duration
 * @return a Duration
 * @since 2.5.0
 */
public static Duration previous(final Duration self) {
  return self.minusSeconds(1);
}

代码示例来源:origin: org.codehaus.groovy/groovy-datetime

/**
 * Returns a {@link java.time.Duration} that is {@code seconds} seconds shorter that this duration.
 *
 * @param self    a Duration
 * @param seconds the number of seconds to subtract
 * @return a Duration
 * @since 2.5.0
 */
public static Duration minus(final Duration self, long seconds) {
  return self.minusSeconds(seconds);
}

代码示例来源:origin: trivago/cluecumber-report-plugin

/**
 * Convert microseconds to a human readable time string.
 *
 * @param microseconds The amount of microseconds.
 * @return The human readable string representation.
 */
public static String convertMicrosecondsToTimeString(final long microseconds) {
  Duration durationMilliseconds = Duration.ofMillis(microseconds / MICROSECOND_FACTOR);
  long minutes = durationMilliseconds.toMinutes();
  long seconds = durationMilliseconds.minusMinutes(minutes).getSeconds();
  long milliseconds = durationMilliseconds.minusMinutes(minutes).minusSeconds(seconds).toMillis();
  return String.format("%dm %02ds %03dms", minutes, seconds, milliseconds);
}

代码示例来源:origin: com.neotys.neoload/neoload-project

protected static String convertToString(final Integer inputInMilliSecond) {
  if (inputInMilliSecond == null) return null;
  if (inputInMilliSecond <= 0) return ZERO;
  Duration duration = Duration.ofMillis(inputInMilliSecond);
  final long hours = duration.toHours();
  duration = duration.minusHours(hours);
  final long minutes = duration.toMinutes();
  duration = duration.minusMinutes(minutes);
  final long seconds = duration.getSeconds();
  duration = duration.minusSeconds(seconds);
  final long milliSeconds = duration.toMillis();
  final StringBuilder sb = new StringBuilder();
  if (hours != 0) {
    sb.append(hours).append(HOURS);
  }
  if (minutes != 0) {
    sb.append(minutes).append(MINUTES);
  }
  if (seconds != 0) {
    sb.append(seconds).append(SECONDS);
  }
  if (milliSeconds != 0) {
    sb.append(milliSeconds).append(MILLISECONDS);
  }
  return sb.toString();
}

代码示例来源:origin: Johnnei/JavaTorrent

public void checkDisconnect() {
  if (strikes >= 5) {
    socket.close();
    return;
  }
  Duration inactiveDuration = Duration.between(socket.getLastActivity(), LocalDateTime.now());
  if (inactiveDuration.minusSeconds(30).isNegative()) {
    // Don't send keep alive yet.
    return;
  }
  socket.enqueueMessage(new MessageKeepAlive());
}

代码示例来源:origin: com.microsoft.rest.v2/client-runtime

duration = duration.minusSeconds(seconds);

代码示例来源:origin: stackoverflow.com

runningTime = runningTime.minusSeconds(5);

代码示例来源:origin: reactiverse/reactive-pg-client

private static Interval binaryDecodeINTERVAL(int index, int len, ByteBuf buff) {
 Duration duration = Duration.of(buff.getLong(index), ChronoUnit.MICROS);
 final long hours = duration.toHours();
 duration = duration.minusHours(hours);
 final long minutes = duration.toMinutes();
 duration = duration.minusMinutes(minutes);
 final long seconds = NANOSECONDS.toSeconds(duration.toNanos());
 duration = duration.minusSeconds(seconds);
 final long microseconds = NANOSECONDS.toMicros(duration.toNanos());
 int days = buff.getInt(index + 8);
 int months = buff.getInt(index + 12);
 Period monthYear = Period.of(0, months, days).normalized();
 return new Interval(monthYear.getYears(), monthYear.getMonths(), monthYear.getDays(),
  (int) hours, (int) minutes, (int) seconds, (int) microseconds);
}

代码示例来源:origin: io.reactiverse/reactive-pg-client

private static Interval binaryDecodeINTERVAL(int index, int len, ByteBuf buff) {
 Duration duration = Duration.of(buff.getLong(index), ChronoUnit.MICROS);
 final long hours = duration.toHours();
 duration = duration.minusHours(hours);
 final long minutes = duration.toMinutes();
 duration = duration.minusMinutes(minutes);
 final long seconds = NANOSECONDS.toSeconds(duration.toNanos());
 duration = duration.minusSeconds(seconds);
 final long microseconds = NANOSECONDS.toMicros(duration.toNanos());
 int days = buff.getInt(index + 8);
 int months = buff.getInt(index + 12);
 Period monthYear = Period.of(0, months, days).normalized();
 return new Interval(monthYear.getYears(), monthYear.getMonths(), monthYear.getDays(),
  (int) hours, (int) minutes, (int) seconds, (int) microseconds);
}

代码示例来源:origin: org.kie/kie-dmn-feel

{ BuiltInType.UNKNOWN, "duration( \"-P5DT4H23M55S\" )", Duration.ofDays( -5 ).minusHours( 4 ).minusMinutes( 23 ).minusSeconds( 55 ) },
{ BuiltInType.UNKNOWN, "duration( \"P23D\" )", Duration.ofDays( 23 ) },
{ BuiltInType.UNKNOWN, "duration( \"-P23D\" )", Duration.ofDays( -23 ) },

代码示例来源:origin: org.kie/kie-dmn-feel

{ BuiltInType.DURATION, "-P5DT4H23M55S", Duration.ofDays( -5 ).minusHours( 4 ).minusMinutes( 23 ).minusSeconds( 55 ) },
{ BuiltInType.DURATION, "P23D", Duration.ofDays( 23 ) },
{ BuiltInType.DURATION, "-P23D", Duration.ofDays( -23 ) },

代码示例来源:origin: org.kie/kie-dmn-feel

{ Duration.ofDays( -5 ).minusHours( 4 ).minusMinutes( 23 ).minusSeconds( 55 ), "-P5DT4H23M55S" },
{ Duration.ofDays( 23 ), "P23D" },
{ Duration.ofDays( -23 ), "-P23D" },

代码示例来源:origin: org.kie/kie-dmn-feel

{ Duration.ofDays( -5 ).minusHours( 4 ).minusMinutes( 23 ).minusSeconds( 55 ), "duration( \"-P5DT4H23M55S\" )" },
{ Duration.ofDays( 23 ), "duration( \"P23D\" )" },
{ Duration.ofDays( -23 ), "duration( \"-P23D\" )" },

代码示例来源:origin: kiegroup/optaweb-employee-rostering

public ShiftTemplateView(Integer rotationLength, ShiftTemplate shiftTemplate) {
  super(shiftTemplate);
  this.spotId = shiftTemplate.getSpot().getId();
  this.rotationEmployeeId = (shiftTemplate.getRotationEmployee() != null) ? shiftTemplate.getRotationEmployee().getId() : null;
  this.durationBetweenRotationStartAndTemplateStart = Duration
      .ofDays(shiftTemplate.getStartDayOffset()).plusSeconds(shiftTemplate
          .getStartTime().toSecondOfDay());
  this.shiftTemplateDuration = Duration
      .ofDays((shiftTemplate.getEndDayOffset() < shiftTemplate.getStartDayOffset()) ? rotationLength : 0)
      .plusDays(shiftTemplate.getEndDayOffset() - shiftTemplate.getStartDayOffset())
      .plusSeconds(shiftTemplate.getEndTime().toSecondOfDay())
      .minusSeconds(shiftTemplate.getStartTime().toSecondOfDay());
}

相关文章