J2ObjC: moved from java.util to keep jre_core independent of jre_time.
Converts a {@code TimeZone} object to a {@code ZoneId}.

@return a {@code ZoneId} representing the same time zone as this
{@code TimeZone}
@since 1.8
190691
public static ZoneId toZoneId(TimeZone tz) {
        // Android-changed: don't support "old mapping"
        return ZoneId.of(tz.getID(), ZoneId.SHORT_IDS);
    }
94070
public DateTimeZone getTimeZone()
    {
        return this.attrValues.get(Person.AttrName.TIMZONE) != null
                        ? DateTimeZone.forID(this.attrValues.get(Person.AttrName.TIMZONE))
                        : DateTimeZone.UTC;
    }
53574
public static DateTime toDateTime(Instant instant, String timeZoneId) {
    return dateTimesHelper.toDateTime(instant, timeZoneId);
  }
39990
public static String changeFormatAndTimeZone(String isoTimestamp,
            String toBeTimeFormat) {
        return changeFormatAndTimeZone(isoTimestamp, toBeTimeFormat,
                DEFAULT_ZONE_ID);
    }
336843
public static String getThreadDefaultTzid() throws TimezonesException {
    final String id = threadTzid.get();

    if (id != null) {
      return id;
    }
    return getSystemDefaultTzid();
  }
284077
public ZonedDateTime getEndZonedDateTime() {
        if (zonedEndDateTime == null) {
            zonedEndDateTime = ZonedDateTime.of(endDate, endTime, zoneId);
        }

        return zonedEndDateTime;
    }
1020153
@Nonnull
  public static ESuccess setDefaultDateTimeZoneID (@Nonnull @Nonempty final String sDateTimeZoneID)
  {
    ValueEnforcer.notEmpty (sDateTimeZoneID, "DateTimeZoneID");

    try
    {
      // Try to resolve ID -> throws exception if unknown
      final ZoneId aDefaultZoneId = ZoneId.of (sDateTimeZoneID);

      // getTimeZone falls back to GMT if unknown
      final TimeZone aDefaultTimeZone = TimeZone.getTimeZone (aDefaultZoneId);

      s_aDefaultZoneId = aDefaultZoneId;
      TimeZone.setDefault (aDefaultTimeZone);
      return ESuccess.SUCCESS;
    }
    catch (final DateTimeException ex)
    {
      // time zone ID is unknown
      LOGGER.warn ("Unsupported ZoneId '" + sDateTimeZoneID + "'", ex);
      return ESuccess.FAILURE;
    }
  }
249412
public T toDateTimeWithTimeZone(String dateTime) {
    return toDateTime(
        ISODateTimeFormat.dateTimeParser().withOffsetParsed().parseDateTime(dateTime));
  }
469045
public static ZoneId getZoneId(String zoneId) {
        return JMMap
                .getOrPutGetNew(zoneIdCache, zoneId, () -> ZoneId.of(zoneId));
    }
557687
static ZonedDateTime getDateFromStringToZoneId(String date, ZoneId zoneId, DateTimeFormatter formatter) throws DateTimeParseException {
        try {
            //noticed that date not parsed with non-US locale. For me this fix is helpful
            LocalDate localDate = LocalDate.parse(date, formatter);
            ZonedDateTime usDate = localDate.atStartOfDay(zoneId);
            return usDate.withZoneSameInstant(zoneId);
        } catch (Exception e) {
            //In case the parsing fail, we try without time
            try {
                ZonedDateTime usDate = LocalDate.parse(date, formatter).atStartOfDay(ZoneId.of(Constants.SHERDOG_TIME_ZONE));
                return usDate.withZoneSameInstant(zoneId);
            } catch (DateTimeParseException e2) {
                return null;
            }
        }
    }
1327968
public DateTime toDateTime(T dateTime) {
    try {
      @SuppressWarnings("unchecked") // Expected class.
      D dateObj = (D) PropertyUtils.getProperty(dateTime, "date");
      String timeZoneId =
          PropertyUtils.isReadable(dateTime, "timeZoneId")
              ? (String) PropertyUtils.getProperty(dateTime, "timeZoneId")
              : (String) PropertyUtils.getProperty(dateTime, "timeZoneID");
      return new DateTime(
          (Integer) PropertyUtils.getProperty(dateObj, "year"),
          (Integer) PropertyUtils.getProperty(dateObj, "month"),
          (Integer) PropertyUtils.getProperty(dateObj, "day"),
          (Integer) PropertyUtils.getProperty(dateTime, "hour"),
          (Integer) PropertyUtils.getProperty(dateTime, "minute"),
          (Integer) PropertyUtils.getProperty(dateTime, "second"),
          0,
          DateTimeZone.forTimeZone(TimeZone.getTimeZone(timeZoneId)));
    } catch (IllegalAccessException e) {
      throw new IllegalStateException("Could not access class.", e);
    } catch (InvocationTargetException e) {
      throw new IllegalStateException("Could not get field.", e);
    } catch (NoSuchMethodException e) {
      throw new IllegalStateException("Could not get field.", e);
    }
  }
163663
private static ZoneRulesProvider getProvider(String zoneId) {
        ZoneRulesProvider provider = ZONES.get(zoneId);
        if (provider == null) {
            if (ZONES.isEmpty()) {
                throw new ZoneRulesException("No time-zone data files registered");
            }
            throw new ZoneRulesException("Unknown time-zone ID: " + zoneId);
        }
        return provider;
    }
769746
public Iterable<DUser> queryByTimeZoneCanonicalId(java.lang.String timeZoneCanonicalId) {
    return queryByField(null, DUserMapper.Field.TIMEZONECANONICALID.getFieldName(), timeZoneCanonicalId);
  }
815579
@Override
    public TZID getID() {

        if (this.id == null) {
            String zoneID = java.util.TimeZone.getDefault().getID();
            return new NamedID(zoneID);
        } else {
            return this.id;
        }

    }
683727
protected static String utcNow() {

    Calendar calendar = Calendar.getInstance();
    SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
    dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
    return dateFormat.format(calendar.getTime());
    // return java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME.format(
    //    ZonedDateTime.now(ZoneOffset.UTC));
  }
357048
public T toDateTime(Instant instant, String timeZoneId) {
    return toDateTime(
        instant.toDateTime(DateTimeZone.forTimeZone(TimeZone.getTimeZone(timeZoneId))));
  }
752047
public static TimeZone getTimeZoneByIdIgnoreCase(String id)
    {
        TimeZone ret = null;
        if(timezones != null)
        {
            id = id.toLowerCase();
            for(int i = 0; i < timezones.length && ret == null; i++)
            {
                if(timezones[i].getId().toLowerCase().equals(id))
                    ret = timezones[i].getTimeZone();
            }
        }
        return ret;
    }