本文整理汇总了Java中org.threeten.bp.LocalDateTime.ofInstant方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDateTime.ofInstant方法的具体用法?Java LocalDateTime.ofInstant怎么用?Java LocalDateTime.ofInstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.threeten.bp.LocalDateTime
的用法示例。
在下文中一共展示了LocalDateTime.ofInstant方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: iterator
import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
@Override
public Iterator<Instant> iterator() {
LocalDateTime at = LocalDateTime.ofInstant(this.at, ZoneOffset.UTC);
LocalDateTime adjustedAt = at.with(adjuster);
final LocalDateTime start = adjustedAt.isBefore(at)
? at.plus(amount).with(adjuster)
: adjustedAt;
return new Iterator<Instant>() {
private LocalDateTime next = start;
@Override
public boolean hasNext() {
return true;
}
@Override
public Instant next() {
Instant result = next.toInstant(ZoneOffset.UTC);
next = next.plus(amount).with(adjuster);
return result;
}
@Override
public void remove() {
throw new UnsupportedOperationException("Schedule iterator does not support remove operation.");
}
};
}
示例2: getDifferenceBetweenTimeAndNow
import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
private Duration getDifferenceBetweenTimeAndNow(long timeStart) {
LocalDateTime today = LocalDateTime.now();
LocalDateTime otherTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timeStart), ZoneId.systemDefault());
return Duration.between(otherTime, today);
}
示例3: shouldUpdateByPassword
import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
private boolean shouldUpdateByPassword(LocalDateTime now, long refreshTime) {
Instant instantRefresh = DateUtils.ofSecond(refreshTime);
LocalDateTime targetRefresh = LocalDateTime.ofInstant(instantRefresh, ZoneId.systemDefault());
return now.isAfter(targetRefresh);
}