本文整理汇总了Java中org.threeten.bp.OffsetDateTime.ofInstant方法的典型用法代码示例。如果您正苦于以下问题:Java OffsetDateTime.ofInstant方法的具体用法?Java OffsetDateTime.ofInstant怎么用?Java OffsetDateTime.ofInstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.threeten.bp.OffsetDateTime
的用法示例。
在下文中一共展示了OffsetDateTime.ofInstant方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.threeten.bp.OffsetDateTime; //导入方法依赖的package包/类
@Override
public OffsetDateTime apply(FromIntegerArguments a) {
return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
}
示例2: printVersionListQuery
import org.threeten.bp.OffsetDateTime; //导入方法依赖的package包/类
private static void printVersionListQuery(SnapshotUtils snapshotUtils, String optionValue) {
DateTimeFormatter dateTimeFormatter = new DateTimeFormatterBuilder()
.appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD)
.appendLiteral('-')
.appendValue(MONTH_OF_YEAR, 2)
.appendLiteral('-')
.appendValue(DAY_OF_MONTH, 2)
.appendValue(HOUR_OF_DAY, 2)
.appendLiteral(':')
.appendValue(MINUTE_OF_HOUR, 2)
.optionalStart()
.appendLiteral(':')
.appendValue(SECOND_OF_MINUTE, 2)
.appendOffsetId()
.toFormatter();
List<VersionInfo> snapshotVersions = snapshotUtils.snapshotVersionsByName(optionValue);
System.out.println(OffsetDateTime.now().toString(dateTimeFormatter));
int fieldWidth = OffsetDateTime.now().toString(dateTimeFormatter).length(); // Assumes all offset date times have same width
header(fieldWidth);
String id = TimeZone.getDefault().getID();
for (VersionInfo versionInfo : snapshotVersions) {
OffsetDateTime versionFrom = versionInfo.getVersionFrom() != null ? OffsetDateTime.ofInstant(versionInfo.getVersionFrom(), ZoneId.of(id)) : null;
OffsetDateTime versionTo = versionInfo.getVersionTo() != null ? OffsetDateTime.ofInstant(versionInfo.getVersionTo(), ZoneId.of(id)) : null;
OffsetDateTime correctionFrom = versionInfo.getCorrectionFrom() != null ? OffsetDateTime.ofInstant(versionInfo.getCorrectionFrom(), ZoneId.of(id)) : null;
OffsetDateTime correctionTo = versionInfo.getCorrectionTo() != null ? OffsetDateTime.ofInstant(versionInfo.getCorrectionTo(), ZoneId.of(id)) : null;
if (versionFrom != null) {
System.out.print(versionFrom.toString(dateTimeFormatter));
} else {
notSpecified(fieldWidth);
}
spaces();
if (versionTo != null) {
System.out.print(versionTo.toString(dateTimeFormatter));
} else {
notSpecified(fieldWidth);
}
spaces();
if (correctionFrom != null) {
System.out.print(correctionFrom.toString(dateTimeFormatter));
} else {
notSpecified(fieldWidth);
}
spaces();
if (correctionTo != null) {
System.out.print(correctionTo.toString(dateTimeFormatter));
} else {
notSpecified(fieldWidth);
}
spaces();
System.out.println(versionInfo.getUniqueId());
}
}
示例3: toSqlTimestamp
import org.threeten.bp.OffsetDateTime; //导入方法依赖的package包/类
/**
* Creates a time-stamp from an {@code InstantProvider}.
*
* @param instant the instant to convert, not null
* @return the SQL time-stamp, not null
*/
public static Timestamp toSqlTimestamp(Instant instant) {
ArgumentChecker.notNull(instant, "instant");
OffsetDateTime utc = OffsetDateTime.ofInstant(instant, ZoneOffset.UTC);
return toSqlDateTime(utc.toLocalDateTime());
}