+
+ /**
+ * Convert the given UTC time (HH:MM) into current timezone of computer
+ * @param inTimeString sunrise/sunset time in UTC (HH:MM)
+ * @return time in this timezone (HH:MM)
+ */
+ private static String convertToLocalTimezone(String inTimeString)
+ {
+ if (inTimeString != null && inTimeString.length() == 5)
+ {
+ try
+ {
+ final int hour = Integer.parseInt(inTimeString.substring(0, 2));
+ final int min = Integer.parseInt(inTimeString.substring(3));
+ Calendar utcCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ utcCal.set(Calendar.HOUR_OF_DAY, hour);
+ utcCal.set(Calendar.MINUTE, min);
+ // Make a second calendar in the current time zone and apply values
+ Calendar currCal = Calendar.getInstance();
+ currCal.setTimeInMillis(utcCal.getTimeInMillis());
+ return DisplayUtils.makeTimeString(currCal.get(Calendar.HOUR_OF_DAY),
+ currCal.get(Calendar.MINUTE));
+ }
+ catch (NumberFormatException e) {} // ignore, just drop through
+ }
+ // Couldn't be parsed / converted
+ return inTimeString;
+ }