本文整理了Java中org.threeten.bp.LocalDateTime.ofInstant()
方法的一些代码示例,展示了LocalDateTime.ofInstant()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDateTime.ofInstant()
方法的具体详情如下:
包路径:org.threeten.bp.LocalDateTime
类名称:LocalDateTime
方法名:ofInstant
[英]Obtains an instance of LocalDateTime from an Instant and zone ID.
This creates a local date-time based on the specified instant. First, the offset from UTC/Greenwich is obtained using the zone ID and instant, which is simple as there is only one valid offset for each instant. Then, the instant and offset are used to calculate the local date-time.
[中]从即时和区域ID获取LocalDateTime的实例。
这将基于指定的瞬间创建本地日期时间。首先,使用区域ID和瞬间获得UTC/格林威治的偏移量,这很简单,因为每个瞬间只有一个有效偏移量。然后,使用即时和偏移量计算本地日期时间。
代码示例来源:origin: apache/servicemix-bundles
@Nonnull
@Override
public LocalDateTime convert(java.time.Instant source) {
return LocalDateTime.ofInstant(Instant.ofEpochMilli(source.toEpochMilli()), ZoneOffset.systemDefault());
}
}
代码示例来源:origin: apache/servicemix-bundles
@Nonnull
@Override
public LocalDateTime convert(Date source) {
return ofInstant(toInstant(source), systemDefault());
}
}
代码示例来源:origin: apache/servicemix-bundles
@Nonnull
@Override
public LocalTime convert(Date source) {
return ofInstant(ofEpochMilli(source.getTime()), systemDefault()).toLocalTime();
}
}
代码示例来源:origin: apache/servicemix-bundles
@Nonnull
@Override
public LocalDate convert(Date source) {
return ofInstant(ofEpochMilli(source.getTime()), systemDefault()).toLocalDate();
}
}
代码示例来源:origin: riggaroo/android-things-electricity-monitor
private Duration getDifferenceBetweenTimeAndNow(long timeStart) {
LocalDateTime today = LocalDateTime.now();
LocalDateTime otherTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timeStart), ZoneId.systemDefault());
return Duration.between(otherTime, today);
}
代码示例来源:origin: com.github.joschi.jackson/jackson-datatype-threetenbp
return LocalDateTime.ofInstant(Instant.parse(string), ZoneOffset.UTC).toLocalDate();
} else {
return LocalDate.parse(string, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
代码示例来源:origin: com.torodb.kvdocument/mongo-converter
LocalDateTime dateTime = LocalDateTime.ofInstant(
instant,
ZoneOffset.UTC
内容来源于网络,如有侵权,请联系作者删除!