什么是Google API中的datetime对象,以及如何格式化其字符串输出?

问题描述 投票:1回答:1
 "start": {
"date": date,
"dateTime": datetime,
"timeZone": string
}...

这来自Google Calendar API Events类(?)的资源表示。 dateTime字段据说是datetime对象。我找不到关于这个类或它的任何函数的任何资源,也没有找到像Date对象那样轻松格式化其字符串输出的方法。

谢谢!

[编辑]从How to convert date in RFC 3339 to the javascript date object(milliseconds since 1970)看起来,DateTime RFC 3339字符串可以解析为Date对象,这应该可以解决问题。

javascript google-api google-calendar-api gapi
1个回答
0
投票

Google Calendar resource documentation中所述,日期时间是RFC3339格式的字符串,例如

"1985-04-12T23:20:50.52Z"

实际上,看起来Google Java客户端库有一个内置的RFC3339格式化程序,可以让这更容易。看到这个答案:How do I parse RFC 3339 datetimes with Java?

© www.soinside.com 2019 - 2024. All rights reserved.