Beispiel #1
0
        //-----------------------------------------------------------------------
        public ChronoLocalDateTimeImpl <D> Plus(long amountToAdd, TemporalUnit unit)
        {
            if (unit is ChronoUnit)
            {
                ChronoUnit f = (ChronoUnit)unit;
                switch (f)
                {
                case NANOS:
                    return(PlusNanos(amountToAdd));

                case MICROS:
                    return(PlusDays(amountToAdd / MICROS_PER_DAY).PlusNanos((amountToAdd % MICROS_PER_DAY) * 1000));

                case MILLIS:
                    return(PlusDays(amountToAdd / MILLIS_PER_DAY).PlusNanos((amountToAdd % MILLIS_PER_DAY) * 1000000));

                case SECONDS:
                    return(PlusSeconds(amountToAdd));

                case MINUTES:
                    return(PlusMinutes(amountToAdd));

                case HOURS:
                    return(PlusHours(amountToAdd));

                case HALF_DAYS:                         // no overflow (256 is multiple of 2)
                    return(PlusDays(amountToAdd / 256).PlusHours((amountToAdd % 256) * 12));
                }
                return(With(Date.Plus(amountToAdd, unit), Time));
            }
            return(ChronoLocalDateTimeImpl.EnsureValid(Date.Chronology, unit.AddTo(this, amountToAdd)));
        }
		//-----------------------------------------------------------------------
		public override ChronoZonedDateTime<D> Plus(long amountToAdd, TemporalUnit unit)
		{
			if (unit is ChronoUnit)
			{
				return with(DateTime.Plus(amountToAdd, unit));
			}
			return ChronoZonedDateTimeImpl.EnsureValid(Chronology, unit.AddTo(this, amountToAdd)); /// TODO: Generics replacement Risk!
		}