예제 #1
0
        /// <summary>
        /// Reads the state from the stream.
        /// </summary>
        /// <param name="in">  the input stream, not null </param>
        /// <returns> the created object, not null </returns>
        /// <exception cref="IOException"> if an error occurs </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: static ZoneOffsetTransitionRule readExternal(java.io.DataInput in) throws java.io.IOException
        internal static ZoneOffsetTransitionRule ReadExternal(DataInput @in)
        {
            int            data       = @in.ReadInt();
            Month          month      = Month.of((int)((uint)data >> 28));
            int            dom        = ((int)((uint)(data & (63 << 22)) >> 22)) - 32;
            int            dowByte    = (int)((uint)(data & (7 << 19)) >> 19);
            DayOfWeek      dow        = dowByte == 0 ? null : DayOfWeek.of(dowByte);
            int            timeByte   = (int)((uint)(data & (31 << 14)) >> 14);
            TimeDefinition defn       = TimeDefinition.values()[(int)((uint)(data & (3 << 12)) >> 12)];
            int            stdByte    = (int)((uint)(data & (255 << 4)) >> 4);
            int            beforeByte = (int)((uint)(data & (3 << 2)) >> 2);
            int            afterByte  = (data & 3);
            LocalTime      time       = (timeByte == 31 ? LocalTime.OfSecondOfDay(@in.ReadInt()) : LocalTime.Of(timeByte % 24, 0));
            ZoneOffset     std        = (stdByte == 255 ? ZoneOffset.OfTotalSeconds(@in.ReadInt()) : ZoneOffset.OfTotalSeconds((stdByte - 128) * 900));
            ZoneOffset     before     = (beforeByte == 3 ? ZoneOffset.OfTotalSeconds(@in.ReadInt()) : ZoneOffset.OfTotalSeconds(std.TotalSeconds + beforeByte * 1800));
            ZoneOffset     after      = (afterByte == 3 ? ZoneOffset.OfTotalSeconds(@in.ReadInt()) : ZoneOffset.OfTotalSeconds(std.TotalSeconds + afterByte * 1800));

            return(ZoneOffsetTransitionRule.Of(month, dom, dow, time, timeByte == 24, defn, std, before, after));
        }
		//-----------------------------------------------------------------------
		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));
		}
예제 #3
0
 //-----------------------------------------------------------------------
 private void ResolveInstantFields()
 {
     // resolve parsed instant seconds to date and time if zone available
     if (FieldValues.ContainsKey(INSTANT_SECONDS))
     {
         if (Zone != java.time.temporal.TemporalAccessor_Fields.Null)
         {
             ResolveInstantFields0(Zone);
         }
         else
         {
             Long offsetSecs = FieldValues[OFFSET_SECONDS];
             if (offsetSecs != java.time.temporal.TemporalAccessor_Fields.Null)
             {
                 ZoneOffset offset = ZoneOffset.OfTotalSeconds(offsetSecs.IntValue());
                 ResolveInstantFields0(offset);
             }
         }
     }
 }
예제 #4
0
 private void ResolveInstant()
 {
     // add instant seconds if we have date, time and zone
     if (Date != java.time.temporal.TemporalAccessor_Fields.Null && Time != java.time.temporal.TemporalAccessor_Fields.Null)
     {
         if (Zone != java.time.temporal.TemporalAccessor_Fields.Null)
         {
             long instant = Date.atTime(Time).atZone(Zone).getLong(ChronoField.INSTANT_SECONDS);
             FieldValues[INSTANT_SECONDS] = instant;
         }
         else
         {
             Long offsetSecs = FieldValues[OFFSET_SECONDS];
             if (offsetSecs != java.time.temporal.TemporalAccessor_Fields.Null)
             {
                 ZoneOffset offset  = ZoneOffset.OfTotalSeconds(offsetSecs.IntValue());
                 long       instant = Date.atTime(Time).atZone(offset).getLong(ChronoField.INSTANT_SECONDS);
                 FieldValues[INSTANT_SECONDS] = instant;
             }
         }
     }
 }
예제 #5
0
        /// <summary>
        /// Reads the state from the stream.
        /// </summary>
        /// <param name="in">  the input stream, not null </param>
        /// <returns> the created object, not null </returns>
        /// <exception cref="IOException"> if an error occurs </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: static java.time.ZoneOffset readOffset(java.io.DataInput in) throws java.io.IOException
        internal static ZoneOffset ReadOffset(DataInput @in)
        {
            int offsetByte = @in.ReadByte();

            return(offsetByte == 127 ? ZoneOffset.OfTotalSeconds(@in.ReadInt()) : ZoneOffset.OfTotalSeconds(offsetByte * 900));
        }