JetBrains/intellij-community · error · DateTimeException

Offset out of range (from -12:00 to +14:00)

Error message

Offset out of range (from -12:00 to +14:00)

What it means

ZonedTimeDelegate.extractOffsetTime throws DateTimeException('Offset out of range (from -12:00 to +14:00)') when an OffsetTime parsed from user input carries a zone offset outside the ISO-8601 real-world bounds MIN_ZONE_OFFSET (-12:00) to MAX_ZONE_OFFSET (+14:00). The grid's zoned-time editor enforces these bounds before accepting the value.

Source

Thrown at grid/core-impl/src/run/ui/grid/editors/ZonedTimeDelegate.java:24

import java.time.LocalTime;
import java.time.OffsetTime;
import java.time.ZoneOffset;
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalAccessor;

public abstract class ZonedTimeDelegate<T> extends DateAndTimeFormatterDelegate<T, TemporalAccessor> {
  private static final ZoneOffset MAX_ZONE_OFFSET = ZoneOffset.of("+14:00");
  private static final ZoneOffset MIN_ZONE_OFFSET = ZoneOffset.of("-12:00");

  public ZonedTimeDelegate() {
    super(ZonedTimeDelegate::extractOffsetTime, ZonedTimeDelegate::extractWithLocalOffset);
  }

  private static TemporalAccessor extractOffsetTime(TemporalAccessor temporal) {
    OffsetTime offsetTime = OffsetTime.from(temporal);
    ZoneOffset offset = offsetTime.getOffset();
    if (MAX_ZONE_OFFSET.compareTo(offset) > 0 || MIN_ZONE_OFFSET.compareTo(offset) < 0) {
      throw new DateTimeException(DataGridBundle.message("zoned.time.out.of.range"));
    }
    return offsetTime;
  }

  private static TemporalAccessor extractWithLocalOffset(TemporalAccessor temporal) {
    if (temporal.isSupported(ChronoField.OFFSET_SECONDS)) {
      throw new DateTimeException(DataGridBundle.message("zoned.time.out.of.range"));
    }
    return LocalTime.from(temporal).atOffset(DataGridFormattersUtilCore.getDefaultOffset());
  }
}

View on GitHub (pinned to be881553f2)

Solutions

  1. Correct the offset in the input to within -12:00..+14:00
  2. Validate the offset before commit: parse ZoneOffset and compare against the bounds
  3. Show an inline editor hint about the accepted offset range when parsing fails

Example fix

// before
OffsetTime t = OffsetTime.parse("15:30+15:00");

// after
OffsetTime t = OffsetTime.parse("15:30+14:00"); // keep offset within -12:00..+14:00
Defensive patterns

Strategy: validation

Validate before calling

static final ZoneOffset MAX = ZoneOffset.of("+14:00"), MIN = ZoneOffset.of("-12:00");
boolean offsetOk(TemporalAccessor t) {
  ZoneOffset o = OffsetTime.from(t).getOffset();
  return MAX.compareTo(o) >= 0 && MIN.compareTo(o) <= 0;
}

Try / catch

catch (DateTimeException e) if 'Offset out of range': keep the editor open and highlight the offset field

Prevention

When it happens

Trigger: Parsing/committing a time string with an offset like +15:30 or -13:00 in a database grid column of type TIME WITH TIME ZONE; OffsetTime.from(temporal) succeeds but the offset comparison fails.

Common situations: User typos in the offset portion of a time literal; data imported from a source with malformed offsets; locales/tools emitting non-standard offsets; testing with synthetic extreme values.

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/955c25c13380b712. Report an issue: GitHub.