谷歌日历,Java:设置谷歌事件颜色和事件日期从时间戳



我正在谷歌日历上工作,我想为事件设置颜色,并从java时间戳对象设置事件时间。目前我找不到任何地方,这是可能的颜色可用和颜色字符串的格式。

下面是我静态日期和时间的代码,没有颜色。我试图使用时间戳,但谷歌有一些奇怪的DateTime对象。另外,我找不到任何默认的颜色格式。包含日期和时间设置的基本示例是静态字符串。这太可怕了,什么样的开发人员会使用硬编码的日期和时间值作为示例来显示他们的日期时间api是怎样的。我希望以后不用再处理这些乱七八糟的API。抱歉,这里是代码:

  @Override
    public Event setUpEventToSave(GroupNotes groupNotes, Person person) {
        Event event = new Event();
        event.setSummary(groupNotes.getMnotetag());
        event.setDescription(groupNotes.getMnotetext());
        Event.Creator creator = new Event.Creator();
        creator.setDisplayName(person.getFirstName());
        creator.setEmail(person.getUsername());
        event.setCreator(creator);
        event.setDescription(groupNotes.getMnotetext());
// I have color in #colorid in DB, but that didn't work, which is standard
      //  event.setColorId(groupNotes.getMnotecolor());
        event.setSummary(groupNotes.getMnotetext());
        event.setLocation("Hamburg");
// How can i pass java timestamp below with system time zone?
        DateTime startDateTime = new DateTime("2015-08-07T09:00:00-07:00");
        EventDateTime start = new EventDateTime()
                .setDateTime(startDateTime)
                .setTimeZone("America/Los_Angeles");
        event.setStart(start);
        DateTime endDateTime = new DateTime("2015-08-07T17:00:00-07:00");
        EventDateTime end = new EventDateTime()
                .setDateTime(endDateTime)
                .setTimeZone("America/Los_Angeles");
        event.setEnd(end);

   /*     EventAttendee[] attendees = new EventAttendee[] {
                new EventAttendee().setEmail("lpage@example.com"),
                new EventAttendee().setEmail("sbrin@example.com"),
        };
        event.setAttendees(Arrays.asList(attendees));
*/
        EventReminder[] reminderOverrides = new EventReminder[] {
                new EventReminder().setMethod("email").setMinutes(24 * 60),
                new EventReminder().setMethod("popup").setMinutes(10),
        };
        Event.Reminders reminders = new Event.Reminders()
                .setUseDefault(false)
                .setOverrides(Arrays.asList(reminderOverrides));
        event.setReminders(reminders);

        return event;
    }

任何帮助都会很好。非常感谢。: -)

您可以在colors endpoint中检查所有可能的颜色。以下是示例回复:

"event": {
  "1": {
  "background": "#a4bdfc",
   "foreground": "#1d1d1d"
  },
 "2": {
 "background": "#7ae7bf",
 "foreground": "#1d1d1d"
},
"3": {
 "background": "#dbadff",
 "foreground": "#1d1d1d"
},
"4": {
 "background": "#ff887c",
 "foreground": "#1d1d1d"
},

插入事件时,使用event。插入时,可以指定colorId。ColorId应该是用颜色表示的。得到响应。你应该给值为colorId="1",它的值如下:" 1 ": {"背景":"# a4bdfc","前景":"# 1 d1d1d"},

如果你还有问题,请告诉我。另外,检查calendarList.update

相关内容

  • 没有找到相关文章

最新更新