本文整理了Java中java.time.Duration.addTo()
方法的一些代码示例,展示了Duration.addTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Duration.addTo()
方法的具体详情如下:
包路径:java.time.Duration
类名称:Duration
方法名:addTo
[英]Adds this duration to the specified temporal object.
This returns a temporal object of the same observable type as the input with this duration added.
In most cases, it is clearer to reverse the calling pattern by using Temporal#plus(TemporalAmount).
// these two lines are equivalent, but the second approach is recommended
dateTime = thisDuration.addTo(dateTime);
dateTime = dateTime.plus(thisDuration);
The calculation will add the seconds, then nanos. Only non-zero amounts will be added.
This instance is immutable and unaffected by this method call.
[中]将此持续时间添加到指定的时间对象。
这将返回一个与输入具有相同可观察类型的时间对象,并添加此持续时间。
在大多数情况下,使用Temporal#plus(TemporalAmount)反转调用模式更为清晰。
// these two lines are equivalent, but the second approach is recommended
dateTime = thisDuration.addTo(dateTime);
dateTime = dateTime.plus(thisDuration);
计算将加上秒数,然后再加上纳秒数。仅添加非零金额。
此实例是不可变的,不受此方法调用的影响。
代码示例来源:origin: metatron-app/metatron-discovery
@Override
public Temporal addTo(final Temporal temporal) {
return duration.addTo(period.addTo(temporal));
}
代码示例来源:origin: com.palantir.conjure.java.api/service-config
@Override
public Temporal addTo(Temporal temporal) {
return toJavaDuration().addTo(temporal);
}
代码示例来源:origin: stackoverflow.com
this.temporal = duration.addTo(BASE_TEMPORAL);
内容来源于网络,如有侵权,请联系作者删除!