Example #1
0
        /// <summary>
        /// Obtains an instance of {@code ChronoPeriodImpl} from a temporal amount.
        /// </summary>
        /// <param name="amount">  the temporal amount to convert, not null </param>
        /// <returns> the period, not null </returns>
        private ChronoPeriodImpl ValidateAmount(TemporalAmount amount)
        {
            Objects.RequireNonNull(amount, "amount");
            if (amount is ChronoPeriodImpl == ChronoPeriod_Fields.False)
            {
                throw new DateTimeException("Unable to obtain ChronoPeriod from TemporalAmount: " + amount.GetType());
            }
            ChronoPeriodImpl period = (ChronoPeriodImpl)amount;

            if (Chrono.Equals(period.Chronology) == ChronoPeriod_Fields.False)
            {
                throw new ClassCastException("Chronology mismatch, expected: " + Chrono.Id + ", actual: " + period.Chronology.Id);
            }
            return(period);
        }
Example #2
0
 private void UpdateCheckConflict(ChronoLocalDate cld)
 {
     if (Date != java.time.temporal.TemporalAccessor_Fields.Null)
     {
         if (cld != java.time.temporal.TemporalAccessor_Fields.Null && Date.Equals(cld) == false)
         {
             throw new DateTimeException("Conflict found: Fields resolved to two different dates: " + Date + " " + cld);
         }
     }
     else if (cld != java.time.temporal.TemporalAccessor_Fields.Null)
     {
         if (Chrono.Equals(cld.Chronology) == false)
         {
             throw new DateTimeException("ChronoLocalDate must use the effective parsed chronology: " + Chrono);
         }
         Date = cld;
     }
 }
Example #3
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Compares this date to another date, including the chronology.
 /// <para>
 /// Compares this {@code HijrahDate} with another ensuring that the date is the same.
 /// </para>
 /// <para>
 /// Only objects of type {@code HijrahDate} are compared, other types return false.
 /// To compare the dates of two {@code TemporalAccessor} instances, including dates
 /// in two different chronologies, use <seealso cref="ChronoField#EPOCH_DAY"/> as a comparator.
 ///
 /// </para>
 /// </summary>
 /// <param name="obj">  the object to check, null returns false </param>
 /// <returns> true if this is equal to the other date and the Chronologies are equal </returns>
 public override bool Equals(Object obj)         // override for performance
 {
     if (this == obj)
     {
         return(true);
     }
     if (obj is HijrahDate)
     {
         HijrahDate otherDate = (HijrahDate)obj;
         return(ProlepticYear == otherDate.ProlepticYear && this.MonthOfYear == otherDate.MonthOfYear && this.DayOfMonth == otherDate.DayOfMonth && Chronology.Equals(otherDate.Chronology));
     }
     return(false);
 }