Gets a {@link TimeZone} instance by the parameter "timeZone" which can be String or {@link TimeZone} or null.

@param timeZone given time zone
@return resolved TimeZone
435208
public static TimeZone resolveTimeZone(Object timeZone) {
        if (timeZone instanceof String) {
            return TimeZone.getTimeZone((String) timeZone);
        }
        else if (timeZone instanceof TimeZone) {
            return (TimeZone) timeZone;
        }
        else {
            return TimeZone.getDefault();
        }
    }
364091
public static Time toTime(TimeZone timeZone, Object o) throws PageException {
	if (o instanceof Time) return (Time) o;
	else if (o instanceof Date) return new TimeImpl((Date) o);
	else if (o instanceof Castable) return new TimeImpl(((Castable) o).castToDateTime());
	else if (o instanceof String) {
	    Time dt = toTime(timeZone, o.toString(), null);
	    if (dt == null) throw new ExpressionException("can't cast [" + o + "] to time value");
	    return dt;
	}
	else if (o instanceof ObjectWrap) return toTime(timeZone, ((ObjectWrap) o).getEmbededObject());
	else if (o instanceof Calendar) {
	    // TODO check timezone offset
	    return new TimeImpl(((Calendar) o).getTimeInMillis(), false);
	}
	throw new ExpressionException("can't cast [" + Caster.toClassName(o) + "] to time value");
    }
279516
public static TimeZone getBrowserTimeZone() {


        if (!StringUtils.isEmpty(fixedTimeZoneProperty)) {
            return TimeZone.getTimeZone(fixedTimeZoneProperty);
        }

        final WebBrowser webBrowser = com.vaadin.server.Page.getCurrent().getWebBrowser();
        final String[] timeZones = TimeZone.getAvailableIDs(webBrowser.getRawTimezoneOffset());
        TimeZone tz = TimeZone.getDefault();
        for (final String string : timeZones) {
            final TimeZone t = TimeZone.getTimeZone(string);
            if (t.getRawOffset() == webBrowser.getRawTimezoneOffset()) {
                tz = t;
            }
        }
        return tz;
    }
946701
public DateTime toDateTime(DateTimeZone zone) {
        zone = DateTimeUtils.getZone(zone);
        if (getZone() == zone) {
            return this;
        }
        return super.toDateTime(zone);
    }
1368710
public static function defaultTimezone($timezone = null)
	{
		if ($timezone !== null)
		{
			if ( ! $timezone instanceOf DateTimeZone)
			{
				$timezone = new DateTimeZone($timezone);
			}

			static::$defaultTimezone = $timezone;
		}

		return static::$defaultTimezone;
	}
274224
final protected function _getTimeZone($timezone = null)
	{
		if ($timezone = strtoupper($timezone) and defined("\\DateTimeZone::{$timezone}")) {
			$timezone = new \DateTimeZone($timezone);
		} elseif (! ($timezone instanceof \DateTimeZone)) {
			@date_default_timezone_set(date_default_timezone_get());
			$timezone = new \DateTimeZone(date_default_timezone_get());
		}
		return $timezone;
	}
1159250
public static function parse($time = null, $timezone = null)
    {
        if ($time instanceof Carbon) {
            return new static(
                $time->toDateTimeString(),
                $timezone ?: $time->getTimezone()
            );
        }

        if (!is_int($time)) {
            $time = static::translateTimeString($time);
        }

        return new static($time, $timezone);
    }
560078
private F getDateTimeInstance(final Integer dateStyle, final Integer timeStyle, final TimeZone timeZone, Locale locale) {
		if (locale == null) {
			locale = Locale.getDefault();
		}
		final String pattern = getPatternForStyle(dateStyle, timeStyle, locale);
		return getInstance(pattern, timeZone, locale);
	}
651063
protected static function getSanitizedTimeZoneString($timezone = null)	//	AKA sanitizeDateTimeZone / getSanitizedTimeZoneString / getValidDateTimeZoneString
	{
		static $timezones	=	null;
		static $abbr		=	null;
		static $dtz			=	null;

		if ($timezone === null)
		{
			return $dtz === null ? $dtz = date_default_timezone_get() : $dtz;
		}
		if (is_string($timezone))
		{
			if ($timezones === null) {
				$timezones = array_flip(\DateTimeZone::listIdentifiers());
			}
			if (isset($timezones[$timezone]))
				return $timezone;

			if ($abbr === null) {
				$timezones = \DateTimeZone::listAbbreviations();
			}
			if (isset($timezones[strtolower($timezone)]))
				return $timezone;

			if (preg_match('(?:GMT)?[-+][01]\d:?\d\d', $timezone) === 1)
				return $timezone;

			return $dtz === null ? $dtz = date_default_timezone_get() : $dtz;
		}
		if ($timezone instanceof \DateTimeZone)
		{
			return $timezone->getName();
		}
		if (is_numeric($timezone))
		{
			$tzName = timezone_name_from_abbr(null, $timezone, true);
			if ($tzName === false)
			{
				throw new \InvalidArgumentException("Unknown or bad timezone ({$timezone})");
			}
			$timezone = $tzName;
		}
		$tz = @timezone_open((string) $timezone);
		if ($tz === false) {
			throw new \InvalidArgumentException("Unknown or bad timezone ({$timezone})");
		}
		return $tz;
	}
840453
public TimeZone getTimeZone()
    {
        // If the TimeZone object is shared by other Calendar instances, then
        // create a clone.
        if (sharedZone) {
            zone = (TimeZone) zone.clone();
            sharedZone = false;
        }
        return zone;
    }
1059326
protected String format(final String pattern, final TimeZone timeZone) {
        return format((Date) getValue(), pattern, timeZone);
    }
410737
protected TimeZone fetchTimeZone(final String id) throws TimezonesException {
    final TaggedTimeZone ttz = fetchTimeZone(id, null);

    if (ttz == null) {
      return null;
    }

    register(id, ttz.tz);

    return ttz.tz;
  }
297790
public function getDeletedAtDatetime(string $timezone = null): ?DateTime
    {
        if (!$this->isDeleted()) {
            return null;
        }

        return new DateTime($this->getDeletedAt(), new DateTimeZone($timezone ?? 'UTC'));
    }
907381
private TimeZone parseTimezone(CharSequenceScanner scanner) {

    int pos = scanner.getCurrentIndex();
    Integer offset = parseTimezoneOffset(scanner);
    // has offset?
    if (offset != null) {
      int offsetMs = offset.intValue();
      String tzName = "GMT";
      if (offsetMs != 0) {
        if (offsetMs < 0) {
          tzName += "-";
        } else {
          tzName += "+";
        }
        tzName += scanner.substring(pos, scanner.getCurrentIndex());
      }
      return new SimpleTimeZone(offsetMs, tzName);
    } else if (scanner.getCurrentIndex() == pos) {
      return null;
    } else {
      // UTC
      return TZ_UTC;
    }
  }
825192
public String resolveTimeZoneId(String zoneId) {
    String alias = _CalendarUtils.getTimeZoneAlias(zoneId);
    if (alias != null) {
      zoneId = alias;
    }
    alias = TimeZoneAliases.getAlias(zoneId);
    if (alias != null) {
      zoneId = alias;
    }
    return zoneId;
  }
1223605
@SuppressWarnings("DeprecatedIsStillUsed")
    @Deprecated
    public void setTimeZone(TimeZone timeZone) {
        mTimezone = timeZone;
        mCalendar.setTimeZone(timeZone);
        YEAR_FORMAT.setTimeZone(timeZone);
        MONTH_FORMAT.setTimeZone(timeZone);
        DAY_FORMAT.setTimeZone(timeZone);
    }
1052538
public static TimeZone getTimeZone(String id) {
        if (id == null) {
            throw new NullPointerException("id == null");
        }

        // Special cases? These can clone an existing instance.
        if (id.length() == 3) {
            if (id.equals("GMT")) {
                return (TimeZone) GMTHolder.INSTANCE.clone();
            }
            if (id.equals("UTC")) {
                return (TimeZone) UTCHolder.INSTANCE.clone();
            }
        }

        // Native time zone?
        TimeZone zone = NativeTimeZone.get(id);

        // Custom time zone?
        if (zone == null && id.length() > 3 && id.startsWith("GMT")) {
            zone = getCustomTimeZone(id);
        }

        // We never return null; on failure we return the equivalent of "GMT".
        return (zone != null) ? zone : (TimeZone) GMTHolder.INSTANCE.clone();
    }