简体   繁体   English

无法通过 api (Java) 在谷歌日历中设置正确的重复周期

[英]can't set right recurrence in google calendar via api (Java)

DateTime startDateTime = new DateTime("2020-12-16T09:00:00-03:00");
EventDateTime start = new EventDateTime()
            .setDateTime(startDateTime)
            .setTimeZone("Europe/Minsk");
event.setStart(start);

DateTime endDateTime = new DateTime("2020-12-16T17:00:00-03:00");
EventDateTime end = new EventDateTime()
            .setDateTime(endDateTime)
            .setTimeZone("Europe/Minsk");
event.setEnd(end);
List<String> recurrences = new ArrayList<>(Arrays.asList("RDATE;VALUE=PERIOD:19960403T020000Z/19960403T040000Z,19960404T010000Z/PT3H"));

Have a problem with setting recurrence.设置重复出现问题。 After executing this code duration in following events is setting like in main event and rule in string is ignoring.在以下事件中执行此代码后,持续时间设置为在主事件中,并且字符串中的规则被忽略。 Can anybody help me solve that?任何人都可以帮我解决这个问题吗?

RFC5545 specifies: RFC5545规定:

If the "RDATE" property is specified as a PERIOD value the duration of the recurrence instance will be the one specified by the "RDATE" property, and not the duration of the recurrence instance defined by the "DTSTART" property.如果“RDATE”属性指定为 PERIOD 值,则重复实例的持续时间将是“RDATE”属性指定的持续时间,而不是“DTSTART”属性定义的重复实例的持续时间。

The Calendar API Events resource specifies:日历 API 事件资源指定:

List of RRULE, EXRULE, RDATE and EXDATE lines for a recurring event, as specified in RFC5545. RFC5545 中指定的重复事件的 RRULE、EXRULE、RDATE 和 EXDATE 行列表。 Note that DTSTART and DTEND lines are not allowed in this field;请注意,该字段中不允许使用 DTSTART 和 DTEND 行; event start and end times are specified in the start and end fields.事件开始和结束时间在开始和结束字段中指定。 This field is omitted for single events or instances of recurring events.对于单个事件或重复事件的实例,该字段被省略。

In other words, VALUE=PERIOD does not seem to be compatible with the Google Calendar API, because it overwrites DTSTART .换句话说, VALUE=PERIOD似乎与 Google 日历 API 不兼容,因为它会覆盖DTSTART

I recommend you to have a look at the Calendar API documentation for recurring events to adjust your recurrent rule accordingly.我建议您查看日历 API 文档以了解周期性事件,以相应地调整您的周期性规则。

For Java, please also keep in mind that it is important to use the UTC date correctly, see here .对于 Java,还请记住正确使用 UTC 日期很重要,请参见此处

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

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