0

我正在尝试使用 google 事件来操作某些特定的东西,我可以添加、删除、获取所有事件并为事件添加颜色,但是我有一个问题,每次我插入一个重复事件时,我都会收到无效的时区消息而且我不知道如何解决它:/

这是我的代码:

public void AddRecurringEvents(日历服务,事件 createdEvent,字符串规则,字符串摘要,字符串位置){

    Event event = new Event();
    // Define Date Time for each start and end time.
    DateTime start = DateTime.parseRfc3339("2014-09-30T10:00:00Z");
    DateTime end = DateTime.parseRfc3339("2014-09-30T10:25:00Z");

    event.setStart(new EventDateTime().setDateTime(start).setTimeZone(
            "Europe/Paris"));
    event.setEnd(new EventDateTime().setDateTime(end).setTimeZone(
            "Europe/Paris"));
    // Setting recurrence
    event.setRecurrence(Arrays.asList(rule));

    try {

        Event recurringEvent = service.events().insert("primary", event)
                .execute();
        System.out.println(createdEvent.getId());
    } catch (IOException e) {

        e.printStackTrace();
    }

}

任何想法如何解决这个问题?我的代码有问题吗...

谢谢

4

1 回答 1

1

尝试这样的事情:

Event event = new Event();

event.setSummary(en.name);
event.setDescription(en.desc);
event.setStatus("confirmed");

ArrayList<String> recurrence = new ArrayList<String>();
recurrence.add("RRULE:FREQ=YEARLY;WKST=MO;"); 
event.setRecurrence(recurrence);

java.util.Calendar cal = java.util.Calendar.getInstance();
cal.set(en.year, en.month-1, en.day,0,0,0);

Date startDate = cal.getTime();
Date endDate = new Date(startDate.getTime()); // same Time

DateTime start = new DateTime(startDate, TimeZone.getTimeZone("Europe/Paris"));
event.setStart(new EventDateTime().setDateTime(start).setTimeZone("Europe/Paris"));

DateTime end = new DateTime(endDate, TimeZone.getTimeZone("Europe/Paris"));
event.setEnd(new EventDateTime().setDateTime(end).setTimeZone("Europe/Paris"));

Event createdEvent = client.events().insert( "primary", event).execute();
于 2014-11-02T14:02:19.140 回答