簡體   English   中英

Google Calendar API V3上的重復活動時區無效

[英]Invalid Timezone for Recurring event on Google Calendar API V3

我正在嘗試使用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();
    }

}

任何想法如何解決這個問題? 我的代碼有什么問題嗎?

謝謝

嘗試這樣的事情:

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();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM