繁体   English   中英

(Java)插入事件时Google日历格式错误

[英](Java) Google Calendar format error when inserting Event

我正在使用Java Google API客户端,并且正在尝试创建Google日历事件。 我能够登录并获取我已经创建的事件。

我一直在关注API示例,但遇到以下错误并查看了其他类似问题,但仍然无法正常工作:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
  "code" : 400,
  "errors" : [ {
"domain" : "global",
"message" : "Invalid value for: \"T\" found, can only parse bare date string: 2017-08-31T12:00:00.000-01:00 Have you accidentally used DateTime instead of a Date?",
"reason" : "invalid"
  } ],
  "message" : "Invalid value for: \"T\" found, can only parse bare date string: 2017-08-31T12:00:00.000-01:00 Have you accidentally used DateTime instead of a Date?"
} 

这是我的代码,我正在将字符串传递到我的DateTimes中:

DateTime startDate = new DateTime(startData);
    EventDateTime start = new EventDateTime();
    start.setDate(startDate);
    start.setTimeZone("Europe/Stockholm");
    DateTime endDate = new DateTime(endData);
    EventDateTime end = new EventDateTime();
    end.setDate(endDate);
    end.setTimeZone("Europe/Stockholm");
    Event event = new Event();
    event.setDescription(lessons.get(i).getDescription());
    event.setStart(start);
    event.setEnd(end);
    event.setLocation(lessons.get(i).getLocation());
    event.setSummary(lessons.get(i).getName())

知道发生了什么事吗?

可能重复。

但是,不久之后-是的,您正在尝试使用需要DateTime格式的函数,但是将不同的日期对象作为参数提供。

“新的DateTime(startData);” startData不是DateTime,而是日期。

请查看这篇文章: Google Calendar API(Java)-创建Google Calendar Event时的时间格式无效

它有您的问题和两个解决方案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM