Search code examples
javascriptgoogle-apigoogle-calendar-apigoogle-api-js-client

What is datetime object in Google API, and how to format its string output?


 "start": {
"date": date,
"dateTime": datetime,
"timeZone": string
}...

This is from the resource representations of Google Calendar API Events class(?). The dateTime field is supposedly a datetime object. I could not find any resources regarding this class or any of its functions, nor did I find a way to easily format its string output like for Date object.

Thank you!

[EDIT]From How to convert date in RFC 3339 to the javascript date object(milliseconds since 1970) it looks like DateTime RFC 3339 string can be parsed into a Date object, which should solve the problem.


Solution

  • As stated in the Google Calendar resource documentation, the datetime is an RFC3339-formatted string, e.g.

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

    In fact, it looks like the Google Java client library has a built-in RFC3339 formatter to make this easier. See this answer: How do I parse RFC 3339 datetimes with Java?