java.time.ZonedDateTime.minusNanos()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(162)

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

ZonedDateTime.minusNanos介绍

[英]Returns a copy of this ZonedDateTime with the specified period in nanoseconds subtracted.

This operates on the instant time-line, such that subtracting one nano will always be a duration of one nano earlier. This may cause the local date-time to change by an amount other than one nano. Note that this is a different approach to that used by days, months and years.

This instance is immutable and unaffected by this method call.
[中]返回此ZoneDateTime的副本,并减去指定的时间段(以纳秒为单位)。
这是在即时时间线上进行的,因此减去一个毫微秒的持续时间将始终为一个毫微秒。这可能会导致本地日期时间的变化量超过一纳诺。请注意,这与日、月和年使用的方法不同。
此实例是不可变的,不受此方法调用的影响。

代码示例

代码示例来源:origin: org.elasticsearch/elasticsearch

public ZonedDateTime minusNanos(long amount) {
  return dt.minusNanos(amount);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

public ZonedDateTime minusNanos(long amount) {
  return dt.minusNanos(amount);
}

代码示例来源:origin: apache/servicemix-bundles

public ZonedDateTime minusNanos(long amount) {
  return dt.minusNanos(amount);
}

代码示例来源:origin: robward-scisys/sldeditor

/**
 * Removes the nano seconds from the current time so the time is output without nano-seconds.
 */
private void removeNanoSeconds() {
  date = date.minusNanos(date.getNano());
}

代码示例来源:origin: com.cronutils/cron-utils

private ExecutionTimeResult getPreviousPotentialMonth(final ZonedDateTime date, final int highestDay, final int highestHour,
    final int highestMinute, final int highestSecond) {
  NearestValue nearestValue;
  ZonedDateTime newDate;
  nearestValue = months.getPreviousValue(date.getMonthValue(), 0);
  final int previousMonths = nearestValue.getValue();
  if (nearestValue.getShifts() > 0) {
    newDate = ZonedDateTime.of(
        LocalDate.of(date.getYear(), 12, 31),
        MAX_SECONDS,
        date.getZone()
    ).minusYears(nearestValue.getShifts());
    return new ExecutionTimeResult(newDate, false);
  }
  else {
    newDate = ZonedDateTime.of(date.getYear(), date.getMonthValue(), 1, 0, 0, 0, 0, date.getZone()).minusNanos(1);
    return new ExecutionTimeResult(newDate, false);
  }
}

相关文章

ZonedDateTime类方法