本文整理了Java中org.threeten.bp.Instant.atZone()
方法的一些代码示例,展示了Instant.atZone()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instant.atZone()
方法的具体详情如下:
包路径:org.threeten.bp.Instant
类名称:Instant
方法名:atZone
[英]Combines this instant with a time-zone to create a ZonedDateTime.
This returns an ZonedDateTime formed from this instant at the specified time-zone. An exception will be thrown if the instant is too large to fit into a zoned date-time.
This method is equivalent to ZonedDateTime#ofInstant(Instant,ZoneId).
[中]将此即时与时区组合以创建ZonedDateTime。
这将返回从此时刻在指定时区形成的ZonedDateTime。如果瞬间太大,无法放入分区日期时间,将引发异常。
此方法相当于ZoneDateTime#of Instant(Instant,ZoneId)。
代码示例来源:origin: jeffdcamp/dbtools-android
@Nullable
public static LocalDateTime longToLocalDateTimeUtc(@Nullable Long l) {
if (l == null) {
return null;
}
return Instant.ofEpochMilli(l).atZone(ZoneOffset.UTC).toLocalDateTime();
}
代码示例来源:origin: XeroAPI/Xero-Java
public OffsetDateTime deserialize(JsonParser jsonparser, DeserializationContext context)
throws IOException, JsonProcessingException {
String date = jsonparser.getText();
OffsetDateTime formattedDate;
Pattern datePatt = Pattern.compile("^/Date\\((\\d+)([+-]\\d+)?\\)/$");
Matcher m = datePatt.matcher(date);
if (m.matches()) {
Long l = Long.parseLong(m.group(1));
formattedDate = Instant.ofEpochMilli(l).atZone(ZoneId.systemDefault()).toOffsetDateTime();
} else {
throw new IllegalArgumentException("Wrong date format");
}
return formattedDate;
}
}
代码示例来源:origin: XeroAPI/Xero-Java
public LocalDate deserialize(JsonParser jsonparser, DeserializationContext context)
throws IOException, JsonProcessingException {
String date = jsonparser.getText();
LocalDate formattedDate;
Pattern datePatt = Pattern.compile("^/Date\\((\\d+)([+-]\\d+)?\\)/$");
Matcher m = datePatt.matcher(date);
if (m.matches()) {
Long l = Long.parseLong(m.group(1));
formattedDate = Instant.ofEpochMilli(l).atZone(ZoneId.systemDefault()).toLocalDate();
} else {
throw new IllegalArgumentException("Wrong date format");
}
return formattedDate;
}
}
代码示例来源:origin: jeffdcamp/dbtools-android
@Nullable
public static LocalDateTime longToLocalDateTime(@Nullable Long l) {
if (l == null) {
return null;
}
return Instant.ofEpochMilli(l).atZone(ZoneId.systemDefault()).toLocalDateTime();
}
代码示例来源:origin: apache/servicemix-bundles
@Nonnull
@Override
public Date convert(Instant source) {
return toDate(source.atZone(systemDefault()).toInstant());
}
}
内容来源于网络,如有侵权,请联系作者删除!