org.threeten.bp.Instant.parse()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(1.4k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中org.threeten.bp.Instant.parse()方法的一些代码示例,展示了Instant.parse()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instant.parse()方法的具体详情如下:
包路径:org.threeten.bp.Instant
类名称:Instant
方法名:parse

Instant.parse介绍

[英]Obtains an instance of Instant from a text string such as 2007-12-23T10:15:30.000Z.

The string must represent a valid instant in UTC and is parsed using DateTimeFormatter#ISO_INSTANT.
[中]从文本字符串(如2007-12-23T10:15:30.000Z)获取Instant的实例。
字符串必须表示UTC中的有效瞬间,并使用DateTimeFormatter#ISO#instant进行解析。

代码示例

代码示例来源:origin: googleapis/google-cloud-java

/**
 * Creates a Timestamp instance from the given string. String is in the RFC 3339 format without
 * the timezone offset (always ends in "Z").
 */
public static Timestamp parseTimestamp(String timestamp) {
 Instant instant = Instant.parse(timestamp);
 return ofTimeSecondsAndNanos(instant.getEpochSecond(), instant.getNano());
}

代码示例来源:origin: com.google.cloud/google-cloud-core

/**
 * Creates a Timestamp instance from the given string. String is in the RFC 3339 format without
 * the timezone offset (always ends in "Z").
 */
public static Timestamp parseTimestamp(String timestamp) {
 Instant instant = Instant.parse(timestamp);
 return ofTimeSecondsAndNanos(instant.getEpochSecond(), instant.getNano());
}

代码示例来源: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);

相关文章