Skip to main content

TimeZone

Represents a timezone for use with DateTime, LocalDate, and Time. Timezones handle daylight saving time transitions and regional offsets automatically.


At a Glance

// Common timezones
const utc = TimeZone.UTC;
const berlin = TimeZone.of('Europe/Berlin');
const tokyo = TimeZone.of('Asia/Tokyo');
const ny = TimeZone.of('America/New_York');

// System default
const local = TimeZone.systemDefault();

// Use with DateTime
const now = DateTime.now(berlin);
stream.logInfo(`Berlin: ${now.toString()}`);

Properties

PropertyTypeDescription
idstringTimezone identifier (e.g., "Europe/Berlin")
displayNamestringHuman-readable name (e.g., "Central European Time")
const tz = TimeZone.of('America/New_York');
stream.logInfo(tz.id); // "America/New_York"
stream.logInfo(tz.displayName); // "Eastern Time"

Static Properties

UTC

The UTC timezone.

const utc = TimeZone.UTC;
stream.logInfo(utc.id); // "UTC"

Methods

of(zoneId)

Returns a TimeZone by its identifier.

ParameterTypeDescription
zoneIdstringTimezone ID (e.g., "Europe/Berlin", "America/New_York")

Returns: TimeZone

const tz = TimeZone.of('Asia/Tokyo');
Finding Timezone IDs

Use standard IANA timezone IDs. A complete list is available at howtodoinjava.com.

systemDefault()

Returns the system's default timezone.

Returns: TimeZone

const local = TimeZone.systemDefault();
stream.logInfo(`Running in: ${local.id}`);

See Also

  • DateTime — Use with DateTime.now(zone) and atZone(zone)
  • ZoneOffset — Fixed UTC offset (e.g., +05:30)