I am currently trying to send calendar invites and I wrote the following code for this:
private void setEventProperties(VEvent vEvent, CalendarDto dto){
vEvent.setSummary(dto.getTitle());
vEvent.setDescription(dto.getDescription());
vEvent.setDateStart(Date.from(dto.getStartDate()));
vEvent.setDateEnd(Date.from(dto.getEndDate()));
vEvent.setOrganizer(dto.getOrganizer());
vEvent.setLocation((String) dto.getMeetingInfo().get("meetingUrl"));
vEvent.setUrl((String) dto.getMeetingInfo().get("meetingUrl"));
for(Attendee attendee: dto.getAttendees()){
attendee.setParticipationLevel(ParticipationLevel.REQUIRED);
vEvent.addAttendee(attendee);
}
}
private String createCalendar(String uuid, CalendarDto dto){
ICalendar iCalendar = new ICalendar();
TimeZone javaTz = TimeZone.getTimeZone("Europe/Istanbul");
String globalId = "Europe/Istanbul";
TimezoneAssignment istanbul = new TimezoneAssignment(javaTz, globalId);
iCalendar.getTimezoneInfo().setDefaultTimezone(istanbul);
iCalendar.addProperty(new Method(Method.REQUEST));
iCalendar.setProductId("----");
VEvent vEvent = new VEvent();
vEvent.setUid(uuid);
vEvent.setStatus(Status.confirmed());
vEvent.setSequence(0);
Date createdDate = new Date();
vEvent.setCreated(createdDate);
vEvent.setLastModified(createdDate);
setEventProperties(vEvent, dto);
iCalendar.addEvent(vEvent);
log.info("Calendar event created with id = '{}'", vEvent.getUid().getValue());
return Biweekly.write(iCalendar).go();
}
Here I am trying to set timezone as "Europe/Istanbul" which is GMT+3 but in gmail it is written as UTC. I also checked the ics file generated.
DTSTAMP:20240123T205158Z STATUS:CONFIRMED SEQUENCE:0 CREATED:20240123T205158Z LAST-MODIFIED:20240123T205158Z DTSTART;TZID=/Europe/Istanbul:20240124T130000 DTEND;TZID=/Europe/Istanbul:20240124T140000
It is setting the timezone correctyl in ics file but in gmail it is shown as below. Example
What might be the reason of this behaviour? I've tried it with my different gmails and in some accounts it set to GMT+3 correctly and I don't know the reason. Versions: biweekly-0.6.7 Java-17
It was actually my mistake. Some of my gmail adresses had different timezones. That was the reason why I get timezone as UTC. Sorry for this question!