Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private static Object readInternal(byte type, java.io.ObjectInput in) throws java.io.IOException, ClassNotFoundException
        private static Object ReadInternal(sbyte type, ObjectInput @in)
        {
            switch (type)
            {
            case CHRONO_TYPE:
                return(AbstractChronology.ReadExternal(@in));

            case CHRONO_LOCAL_DATE_TIME_TYPE:
                return(ChronoLocalDateTimeImpl.ReadExternal(@in));

            case CHRONO_ZONE_DATE_TIME_TYPE:
                return(ChronoZonedDateTimeImpl.ReadExternal(@in));

            case JAPANESE_DATE_TYPE:
                return(JapaneseDate.ReadExternal(@in));

            case JAPANESE_ERA_TYPE:
                return(JapaneseEra.ReadExternal(@in));

            case HIJRAH_DATE_TYPE:
                return(HijrahDate.ReadExternal(@in));

            case MINGUO_DATE_TYPE:
                return(MinguoDate.ReadExternal(@in));

            case THAIBUDDHIST_DATE_TYPE:
                return(ThaiBuddhistDate.ReadExternal(@in));

            case CHRONO_PERIOD_TYPE:
                return(ChronoPeriodImpl.ReadExternal(@in));

            default:
                throw new StreamCorruptedException("Unknown serialized type");
            }
        }
Пример #2
0
 //-----------------------------------------------------------------------
 public override bool Equals(Object obj)
 {
     if (this == obj)
     {
         return(ChronoPeriod_Fields.True);
     }
     if (obj is ChronoPeriodImpl)
     {
         ChronoPeriodImpl other = (ChronoPeriodImpl)obj;
         return(Years == other.Years && Months == other.Months && Days == other.Days && Chrono.Equals(other.Chrono));
     }
     return(ChronoPeriod_Fields.False);
 }
Пример #3
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);
        }
Пример #4
0
        public ChronoPeriod Minus(TemporalAmount amountToSubtract)
        {
            ChronoPeriodImpl amount = ValidateAmount(amountToSubtract);

            return(new ChronoPeriodImpl(Chrono, Math.SubtractExact(Years, amount.Years), Math.SubtractExact(Months, amount.Months), Math.SubtractExact(Days, amount.Days)));
        }
Пример #5
0
        //-----------------------------------------------------------------------
        public ChronoPeriod Plus(TemporalAmount amountToAdd)
        {
            ChronoPeriodImpl amount = ValidateAmount(amountToAdd);

            return(new ChronoPeriodImpl(Chrono, Math.AddExact(Years, amount.Years), Math.AddExact(Months, amount.Months), Math.AddExact(Days, amount.Days)));
        }