From 828254a1f76a1938460a124354417623c973ac37 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 4 Jan 2019 20:32:35 +0000 Subject: [PATCH] Event invites: gracefully handle missing timezone information. The code before didn't fallback to UTC nicely and was causing a crash. --- .../syncadapter/syncadapter/CalendarSyncManager.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarSyncManager.java b/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarSyncManager.java index 28b441f1..f79a6118 100644 --- a/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarSyncManager.java +++ b/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarSyncManager.java @@ -224,7 +224,7 @@ public class CalendarSyncManager extends SyncManager { private static String formatEventDates(Event event) { final Locale locale = Locale.getDefault(); - final TimeZone timezone = event.dtStart.getTimeZone(); + final TimeZone timezone = (event.dtStart.getTimeZone() != null) ? event.dtStart.getTimeZone() : TimeZone.getTimeZone("UTC"); final String dateFormatString = event.isAllDay() ? "EEEE, MMM dd" : "EEEE, MMM dd @ hh:mm a"; final DateFormat longDateFormat = @@ -236,9 +236,8 @@ public class CalendarSyncManager extends SyncManager { Date startDate = event.dtStart.getDate(); Date endDate = event.getEndDate(true).getDate(); - final String tzName = (timezone != null) ? - timezone.getDisplayName(timezone.inDaylightTime(startDate), TimeZone.SHORT) - : "UTC"; + final String tzName = timezone.getDisplayName(timezone.inDaylightTime(startDate), TimeZone.SHORT); + Calendar cal1 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); cal1.setTime(startDate);