/// <summary> /// Obtains an instance from an instant using the specified time-zone. /// </summary> /// <param name="chrono"> the chronology, not null </param> /// <param name="instant"> the instant, not null </param> /// <param name="zone"> the zone identifier, not null </param> /// <returns> the zoned date-time, not null </returns> //JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET: //ORIGINAL LINE: static ChronoZonedDateTimeImpl<?> ofInstant(Chronology ChronoZonedDateTime_Fields.chrono, java.time.Instant instant, java.time.ZoneId zone) internal static ChronoZonedDateTimeImpl<?> OfInstant(Chronology ChronoZonedDateTime_Fields, Instant instant, ZoneId zone) { ZoneRules rules = zone.Rules; ZoneOffset offset = rules.GetOffset(instant); Objects.RequireNonNull(offset, "offset"); // protect against bad ZoneRules LocalDateTime ldt = LocalDateTime.OfEpochSecond(instant.EpochSecond, instant.Nano, offset); //JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET: //ORIGINAL LINE: ChronoLocalDateTimeImpl<?> cldt = (ChronoLocalDateTimeImpl<?>)ChronoZonedDateTime_Fields.chrono.localDateTime(ldt); ChronoLocalDateTimeImpl<?> cldt = (ChronoLocalDateTimeImpl<?>)ChronoZonedDateTime_Fields.Chrono.localDateTime(ldt); return new ChronoZonedDateTimeImpl<>(cldt, offset, zone); }
/// <summary> /// Normalizes the time-zone ID, returning a {@code ZoneOffset} where possible. /// <para> /// The returns a normalized {@code ZoneId} that can be used in place of this ID. /// The result will have {@code ZoneRules} equivalent to those returned by this object, /// however the ID returned by {@code getId()} may be different. /// </para> /// <para> /// The normalization checks if the rules of this {@code ZoneId} have a fixed offset. /// If they do, then the {@code ZoneOffset} equal to that offset is returned. /// Otherwise {@code this} is returned. /// /// </para> /// </summary> /// <returns> the time-zone unique ID, not null </returns> public virtual ZoneId Normalized() { try { ZoneRules rules = Rules; if (rules.FixedOffset) { return(rules.GetOffset(Instant.EPOCH)); } } catch (ZoneRulesException) { // invalid ZoneRegion is not important to this method } return(this); }