Google日历,Java:从时间戳设置Google事件颜色和事件日期 [英] Google Calendar, Java : Set up google event colour and event date from timestamp

查看:244
本文介绍了Google日历,Java:从时间戳设置Google事件颜色和事件日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Google日历上工作,我想为事件设置颜色,并设置java时间戳对象的事件时间。目前我找不到可用的颜色和颜色字符串的格式。

I am working on Google calendar and I would like to set colour for an event and to set event time from java timestamp object I have. Currently I cannot find anywhere which are the possible colors available and the format of colour string.

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

Below is the code I have with static date and time, and no colour. I tried to use the timestamp, but Google has some weird DateTime object. Also, I am unable to find any default format for colors. THe basic sample which contains date and time setting are static strings. That's so horrible, what kind of developer uses hardcoded date and time values as example to show how their date time api is. I hope I don't have to deal with such messed up API in future. Sorry for ranting, here is code :

  @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;
    }

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

Any help would be nice. Thanks a lot. :-)

推荐答案

您可以在颜色端点。以下是示例响应:

You can check all the possible colors in colors endpoint. Here is the sample response:

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

在插入事件时,使用 event.insert ,可以指定colorId。 ColorId应该是color.get响应中的一个。你应该赋值为colorId =1,它取值如下:
1:{
background:#a4bdfc,
foreground:#1d1d1d
},

While inserting event, using event.insert, you can specify colorId. ColorId should be the one which is in colors.get response. You should give value as colorId="1" which takes value as below: "1": { "background": "#a4bdfc", "foreground": "#1d1d1d" },

如果您还有问题,请告诉我们。另外,请查看 calendarList.update

Let me know if you still have issues. Also, check calendarList.update

这篇关于Google日历,Java:从时间戳设置Google事件颜色和事件日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆