예제 #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");
            }
        }
		//-----------------------------------------------------------------------
		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!
		}
		/// <summary>
		/// Casts the {@code Temporal} to {@code ChronoZonedDateTimeImpl} ensuring it bas the specified chronology.
		/// </summary>
		/// <param name="chrono">  the chronology to check for, not null </param>
		/// <param name="temporal">  a date-time to cast, not null </param>
		/// <returns> the date-time checked and cast to {@code ChronoZonedDateTimeImpl}, not null </returns>
		/// <exception cref="ClassCastException"> if the date-time cannot be cast to ChronoZonedDateTimeImpl
		///  or the chronology is not equal this Chronology </exception>
		internal static ChronoZonedDateTimeImpl<R> ensureValid<R>(Chronology ChronoZonedDateTime_Fields, Temporal temporal) where R : ChronoLocalDate
		{
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") ChronoZonedDateTimeImpl<R> other = (ChronoZonedDateTimeImpl<R>) temporal;
			ChronoZonedDateTimeImpl<R> other = (ChronoZonedDateTimeImpl<R>) temporal;
			if (ChronoZonedDateTime_Fields.Chrono.Equals(other.Chronology) == false)
			{
				throw new ClassCastException("Chronology mismatch, required: " + ChronoZonedDateTime_Fields.Chrono.Id + ", actual: " + other.Chronology.Id);
			}
			return other;
		}
		//-----------------------------------------------------------------------
		public override ChronoZonedDateTime<D> With(TemporalField field, long newValue)
		{
			if (field is ChronoField)
			{
				ChronoField f = (ChronoField) field;
				switch (f)
				{
					case INSTANT_SECONDS:
						return Plus(newValue - toEpochSecond(), SECONDS);
					case OFFSET_SECONDS:
					{
						ZoneOffset offset = ZoneOffset.OfTotalSeconds(f.checkValidIntValue(newValue));
						return Create(DateTime.toInstant(offset), Zone_Renamed);
					}
				}
				return OfBest(DateTime.With(field, newValue), Zone_Renamed, Offset_Renamed);
			}
			return ChronoZonedDateTimeImpl.EnsureValid(Chronology, field.AdjustInto(this, newValue));
		}
예제 #5
0
 //-----------------------------------------------------------------------
 public override ChronoZonedDateTime <D> AtZone(ZoneId zone)
 {
     return(ChronoZonedDateTimeImpl.OfBest(this, zone, ChronoLocalDateTime_Fields.Null));
 }