public Event(com.google.api.services.calendar.model.Event current, int $colorNumber) { name = current.getSummary(); summary = current.getDescription(); Calendar calS = Calendar.getInstance(); Calendar calE = Calendar.getInstance(); colorNumber = $colorNumber; // cal.setTimeInMillis(current.getStart().getDateTime().getValue()); // startDate = cal; if (current.getStart().getDate() != null) { String[] date = current.getStart().getDate().toString().split("-"); calS.set(Integer.parseInt(date[0]), Integer.parseInt(date[1]) - 1, Integer.parseInt(date[2])); date = current.getEnd().getDate().toString().split("-"); calE.set(Integer.parseInt(date[0]), Integer.parseInt(date[1]) - 1, Integer.parseInt(date[2])); startDate = calS; endDate = calE; } else { String date = current.getStart().getDateTime().toString(); int dateCutoff = date.indexOf("T"); int timeCutoff = date.indexOf("."); // to remove nanoseconds if (timeCutoff == -1) // if nanoseconds not set remove timezone shift timeCutoff = date.indexOf("-"); if (timeCutoff == -1) // if timezone shift not set isolate time only timeCutoff = date.indexOf("Z"); String time = date.substring(dateCutoff + 1, timeCutoff); String[] timeC = time.split(":"); date = date.substring(0, dateCutoff); String[] dateC = date.split("-"); calS.set( Integer.parseInt(dateC[0]), Integer.parseInt(dateC[1]) - 1, Integer.parseInt(dateC[2]), Integer.parseInt(timeC[0]), Integer.parseInt(timeC[1]), Integer.parseInt(timeC[2])); date = current.getEnd().getDateTime().toString(); timeCutoff = date.indexOf("."); dateCutoff = date.indexOf("T"); // to remove nanoseconds if (timeCutoff == -1) // if nanoseconds not set remove timezone shift timeCutoff = date.indexOf("-"); if (timeCutoff == -1) // if timezone shift not set isolate time only timeCutoff = date.indexOf("Z"); time = date.substring(dateCutoff + 1, timeCutoff); String[] timeE = time.split(":"); date = date.substring(0, dateCutoff); dateC = date.split("-"); calE.set( Integer.parseInt(dateC[0]), Integer.parseInt(dateC[1]) - 1, Integer.parseInt(dateC[2]), Integer.parseInt(timeE[0]), Integer.parseInt(timeE[1]), Integer.parseInt(timeE[2])); startDate = calS; endDate = calE; } id = current.getId(); calendarName = current.getOrganizer().getDisplayName(); // cal.setTimeInMillis(current.getEnd().getDateTime().getValue()); // endDate = cal; }