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)

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

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)

将以长型形式传递的纪元毫秒数时间戳转换为根据提供的时区和格式设置的时间戳。