public Event newEvent(DateTime start, DateTime end, String title) {
    Event event = new Event();
    event.setSummary(title);
    Date startDate = new Date();
    Date endDate = new Date(startDate.getTime() + 3600000);

    event.setStart(new EventDateTime().setDateTime(start));
    event.setEnd(new EventDateTime().setDateTime(end));
    return event;
  }
  public void createCalEvent(Date startDate, Date endDate, String summary, String desc)
      throws IOException {

    com.google.api.services.calendar.Calendar service = getCalendarService();
    Event createEvent = new Event().setSummary(summary).setDescription(desc);

    DateTime startTime = new DateTime(startDate);
    DateTime endTime = new DateTime(endDate);

    EventDateTime start = new EventDateTime().setDateTime(startTime).setTimeZone("Asia/Kolkata");

    createEvent.setStart(start);

    EventDateTime end = new EventDateTime().setDateTime(endTime).setTimeZone("Asia/Kolkata");

    createEvent.setEnd(end);

    EventAttendee[] attendees =
        new EventAttendee[] {
          new EventAttendee().setEmail("*****@*****.**"),
          new EventAttendee().setEmail("*****@*****.**"),
          new EventAttendee().setEmail("*****@*****.**")
        };

    createEvent.setAttendees(Arrays.asList(attendees));

    EventReminder[] reminderOverrides =
        new EventReminder[] {new EventReminder().setMethod("popup").setMinutes(10)};

    Event.Reminders reminders =
        new Event.Reminders().setUseDefault(false).setOverrides(Arrays.asList(reminderOverrides));

    createEvent.setReminders(reminders);

    String calendarId = "primary";
    createEvent = service.events().insert(calendarId, createEvent).execute();
    System.out.printf("Event created: %s\n", createEvent.getHtmlLink());
  }
  private Event createEvent(
      String roomName,
      String yearNum,
      String monthNum,
      String dayNum,
      String eventTime,
      String firmanavn,
      String attendeeEmail,
      String besrkivelse) {
    Event event = null;

    Calendar startCal = null;
    Calendar endCal = null;

    try {
      int year = Integer.parseInt(yearNum);
      int month = Integer.parseInt(monthNum) - 1;
      int day = Integer.parseInt(dayNum);

      startCal = Calendar.getInstance();
      startCal.set(Calendar.YEAR, year);
      startCal.set(Calendar.MONTH, month);
      startCal.set(Calendar.DATE, day);

      endCal = Calendar.getInstance();
      endCal.set(Calendar.YEAR, year);
      endCal.set(Calendar.MONTH, month);
      endCal.set(Calendar.DATE, day);

      if (eventTime.equals("early")) {
        startCal.set(Calendar.HOUR_OF_DAY, 8);
        endCal.set(Calendar.HOUR_OF_DAY, 12);
      } else if (eventTime.equals("late")) {
        startCal.set(Calendar.HOUR_OF_DAY, 13);
        endCal.set(Calendar.HOUR_OF_DAY, 17);
      } else if (eventTime.equals("full")) {
        startCal.set(Calendar.HOUR_OF_DAY, 8);
        endCal.set(Calendar.HOUR_OF_DAY, 17);
      } else if (eventTime.equals("community")) {
        startCal.set(Calendar.HOUR_OF_DAY, 17);
        startCal.set(Calendar.MINUTE, 1);
        endCal.set(Calendar.HOUR_OF_DAY, 22);
      } else {
        int startHour = Integer.parseInt(eventTime);
        startCal.set(Calendar.HOUR_OF_DAY, startHour);
        endCal.set(Calendar.HOUR_OF_DAY, (startHour + 1));
      }

      startCal.set(Calendar.MINUTE, 0);
      endCal.set(Calendar.MINUTE, 0);

      event = new Event();
      DateTime start = new DateTime(startCal.getTime(), TimeZone.getTimeZone("UTC"));
      event.setStart(new EventDateTime().setDateTime(start));
      DateTime end = new DateTime(endCal.getTime(), TimeZone.getTimeZone("UTC"));
      event.setEnd(new EventDateTime().setDateTime(end));

      event.setSummary(firmanavn);
      event.setLocation(roomName);
      event.setDescription(besrkivelse);

      EventAttendee room = new EventAttendee();
      room.setDisplayName(roomName);
      room.setEmail("*****@*****.**");

      List<EventAttendee> attendeeList = new ArrayList<>();
      attendeeList.add(room);

      EventAttendee attendee = new EventAttendee();
      attendee.setDisplayName(firmanavn);
      attendee.setEmail(attendeeEmail);
      attendeeList.add(attendee);

      event.setAttendees(attendeeList);

      GoogleCal googleCal = GoogleCal.getInstance();
      event = googleCal.addEvent(event);
    } catch (NumberFormatException nfe) {
      nfe.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }

    return event;
  }