util.time 中的时间助手 - Amazon AppSync
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

util.time 中的时间助手

util.time 变量包含的日期时间方法有助于生成时间截,在不同的日期时间格式之间进行转换,并解析日期时间字符串。日期时间格式的语法以此为基础 DateTimeFormatter,您可以参考该语法以获取更多文档。我们在下面提供一些示例,以及可用方法和描述的列表。

时间效用

util.time.nowISO8601()

返回 UTC 的 ISO8601 格式字符串表示形式。

util.time.nowEpochSeconds()

返回从 1970-01-01T00:00:00Z 纪元到现在的秒数。

util.time.nowEpochMilliSeconds()

返回从 1970-01-01T00:00:00Z 纪元到现在的毫秒数。

util.time.nowFormatted(String)

使用字符串输入类型指定的格式返回当前 UTC 时间戳的字符串。

util.time.nowFormatted(String, String)

使用字符串输入类型指定的格式和时区返回该时区当前时间戳的字符串。

util.time.parseFormattedToEpochMilliSeconds(String, String)

解析以字符串形式传递的时间戳以及格式,然后以自纪元以来的毫秒数返回时间戳。

util.time.parseFormattedToEpochMilliSeconds(String, String, String)

解析以 String 形式传递的时间戳以及格式和时区,然后以自纪元以来的毫秒返回时间戳。

util.time.parseISO8601ToEpochMilliSeconds(String)

解析以字符串形式传递的 ISO8601 时间戳,然后以自纪元以来的毫秒返回时间戳。

util.time.epochMilliSecondsToSeconds(long)

将纪元毫秒数时间戳转换为纪元秒数时间戳。

util.time.epochMilliSecondsToISO8601(long)

将纪元毫秒时间戳转换为 ISO8601 时间戳。

util.time.epochMilliSecondsToFormatted(long, String)

将传递同样长的时代毫秒时间戳转换为根据所提供的 UTC 格式进行格式化的时间戳。

util.time.epochMilliSecondsToFormatted(long, String, String)

将以长形式传递的纪元毫秒时间戳转换为根据所提供时区中提供的格式进行格式化的时间戳。