//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") @Override public <R> R query(java.time.temporal.TemporalQuery<R> query) public override R query <R>(TemporalQuery <R> query) { if (query == TemporalQueries.ZoneId()) { return((R)Zone); } else if (query == TemporalQueries.Chronology()) { return((R)Chrono); } else if (query == TemporalQueries.LocalDate()) { return((R)(Date != java.time.temporal.TemporalAccessor_Fields.Null ? LocalDate.From(Date) : java.time.temporal.TemporalAccessor_Fields.Null)); } else if (query == TemporalQueries.LocalTime()) { return((R)Time); } else if (query == TemporalQueries.Zone() || query == TemporalQueries.Offset()) { return(query.QueryFrom(this)); } else if (query == TemporalQueries.Precision()) { return(java.time.temporal.TemporalAccessor_Fields.Null); // not a complete date/time } // inline TemporalAccessor.super.query(query) as an optimization // non-JDK classes are not permitted to make this optimization return(query.QueryFrom(this)); }
//----------------------------------------------------------------------- /// <summary> /// Queries this offset using the specified query. /// <para> /// This queries this offset using the specified query strategy object. /// The {@code TemporalQuery} object defines the logic to be used to /// obtain the result. Read the documentation of the query to understand /// what the result of this method will be. /// </para> /// <para> /// The result of this method is obtained by invoking the /// <seealso cref="TemporalQuery#queryFrom(TemporalAccessor)"/> method on the /// specified query passing {@code this} as the argument. /// /// </para> /// </summary> /// @param <R> the type of the result </param> /// <param name="query"> the query to invoke, not null </param> /// <returns> the query result, null may be returned (defined by the query) </returns> /// <exception cref="DateTimeException"> if unable to query (defined by the query) </exception> /// <exception cref="ArithmeticException"> if numeric overflow occurs (defined by the query) </exception> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") @Override public <R> R query(java.time.temporal.TemporalQuery<R> query) public override R query <R>(TemporalQuery <R> query) { if (query == TemporalQueries.Offset() || query == TemporalQueries.Zone()) { return((R)this); } return(TemporalAccessor.this.query(query)); }
//----------------------------------------------------------------------- /// <summary> /// Obtains an instance of {@code ZoneOffset} from a temporal object. /// <para> /// This obtains an offset based on the specified temporal. /// A {@code TemporalAccessor} represents an arbitrary set of date and time information, /// which this factory converts to an instance of {@code ZoneOffset}. /// </para> /// <para> /// A {@code TemporalAccessor} represents some form of date and time information. /// This factory converts the arbitrary temporal object to an instance of {@code ZoneOffset}. /// </para> /// <para> /// The conversion uses the <seealso cref="TemporalQueries#offset()"/> query, which relies /// on extracting the <seealso cref="ChronoField#OFFSET_SECONDS OFFSET_SECONDS"/> field. /// </para> /// <para> /// This method matches the signature of the functional interface <seealso cref="TemporalQuery"/> /// allowing it to be used as a query via method reference, {@code ZoneOffset::from}. /// /// </para> /// </summary> /// <param name="temporal"> the temporal object to convert, not null </param> /// <returns> the zone-offset, not null </returns> /// <exception cref="DateTimeException"> if unable to convert to an {@code ZoneOffset} </exception> public static ZoneOffset From(TemporalAccessor temporal) { Objects.RequireNonNull(temporal, "temporal"); ZoneOffset offset = temporal.query(TemporalQueries.Offset()); if (offset == temporal.TemporalAccessor_Fields.Null) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: throw new DateTimeException("Unable to obtain ZoneOffset from TemporalAccessor: " + temporal + " of type " + temporal.GetType().FullName); } return(offset); }