List of usage examples for java.time ZoneOffset ofTotalSeconds
public static ZoneOffset ofTotalSeconds(int totalSeconds)
The offset must be in the range -18:00 to +18:00 , which corresponds to -64800 to +64800.
From source file:Main.java
public static void main(String[] args) { ZoneOffset t = ZoneOffset.ofTotalSeconds(2000); System.out.println(t); }
From source file:msi.gama.util.GamaDate.java
public GamaDate(final IScope scope, final Temporal d) { final ZoneId zone; if (d instanceof ChronoZonedDateTime) { zone = ZonedDateTime.from(d).getZone(); } else if (d.isSupported(ChronoField.OFFSET_SECONDS)) { zone = ZoneId.ofOffset("", ZoneOffset.ofTotalSeconds(d.get(ChronoField.OFFSET_SECONDS))); } else {//from w ww . jav a2s . c o m zone = GamaDateType.DEFAULT_ZONE; } if (!d.isSupported(MINUTE_OF_HOUR)) { internal = ZonedDateTime.of(LocalDate.from(d), LocalTime.of(0, 0), zone); } else if (!d.isSupported(DAY_OF_MONTH)) { internal = ZonedDateTime.of(LocalDate.from( scope == null ? Dates.DATES_STARTING_DATE.getValue() : scope.getSimulation().getStartingDate()), LocalTime.from(d), zone); } else { internal = d; } }
From source file:org.openmhealth.shim.jawbone.mapper.JawboneDataPointMapper.java
/** * Translates a time zone descriptor from one of various representations (Olson, seconds offset, GMT offset) into a * {@link ZoneId}.//from w ww . j av a 2 s. co m * * @param timeZoneValueNode the value associated with a timezone property */ static ZoneId parseZone(JsonNode timeZoneValueNode) { // default to UTC if timezone is not present if (timeZoneValueNode.isNull()) { return ZoneOffset.UTC; } // "-25200" if (timeZoneValueNode.asInt() != 0) { ZoneOffset zoneOffset = ZoneOffset.ofTotalSeconds(timeZoneValueNode.asInt()); // TODO confirm if this is even necessary, since ZoneOffset is a ZoneId return ZoneId.ofOffset("GMT", zoneOffset); } // e.g., "GMT-0700" or "America/Los_Angeles" if (timeZoneValueNode.isTextual()) { return ZoneId.of(timeZoneValueNode.textValue()); } throw new IllegalArgumentException(format("The time zone node '%s' can't be parsed.", timeZoneValueNode)); }