//----------------------------------------------------------------------- public override ValueRange java.time.temporal.TemporalAccessor_Fields.range(TemporalField field) { if (field is ChronoField) { if (IsSupported(field)) { ChronoField f = (ChronoField)field; switch (f) { case DAY_OF_MONTH: return(ValueRange.Of(1, LengthOfMonth())); case DAY_OF_YEAR: return(ValueRange.Of(1, LengthOfYear())); case ALIGNED_WEEK_OF_MONTH: // TODO return(ValueRange.Of(1, 5)); // TODO does the limited range of valid years cause years to // start/end part way through? that would affect range } return(Chronology.Range(f)); } throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return(field.RangeRefinedBy(this)); }
public override ValueRange java.time.temporal.TemporalAccessor_Fields.range(TemporalField field) { if (field is ChronoField) { if (IsSupported(field)) { ChronoField f = (ChronoField)field; switch (f) { case DAY_OF_MONTH: return(ValueRange.Of(1, LengthOfMonth())); case DAY_OF_YEAR: return(ValueRange.Of(1, LengthOfYear())); case YEAR_OF_ERA: { DateTime jcal = DateTime.GetInstance(JapaneseChronology.LOCALE); jcal.set(DateTime.ERA, Era_Renamed.Value + JapaneseEra.ERA_OFFSET); jcal = new DateTime(YearOfEra, IsoDate.MonthValue - 1, IsoDate.DayOfMonth); return(ValueRange.Of(1, jcal.getActualMaximum(DateTime.YEAR))); } } return(Chronology.Range(f)); } throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return(field.RangeRefinedBy(this)); }
//----------------------------------------------------------------------- public override String ToString() { if (Zero) { return(Chronology.ToString() + " P0D"); } else { StringBuilder buf = new StringBuilder(); buf.Append(Chronology.ToString()).Append(' ').Append('P'); if (Years != 0) { buf.Append(Years).Append('Y'); } if (Months != 0) { buf.Append(Months).Append('M'); } if (Days != 0) { buf.Append(Days).Append('D'); } return(buf.ToString()); } }
//----------------------------------------------------------------------- public override ValueRange java.time.temporal.TemporalAccessor_Fields.range(TemporalField field) { if (field is ChronoField) { if (IsSupported(field)) { ChronoField f = (ChronoField)field; switch (f) { case DAY_OF_MONTH: case DAY_OF_YEAR: case ALIGNED_WEEK_OF_MONTH: return(IsoDate.Range(field)); case YEAR_OF_ERA: { ValueRange java.time.temporal.TemporalAccessor_Fields.Range = YEAR.range(); long max = (ProlepticYear <= 0 ? -java.time.temporal.TemporalAccessor_Fields.Range.Minimum + 1 + YEARS_DIFFERENCE : java.time.temporal.TemporalAccessor_Fields.Range.Maximum - YEARS_DIFFERENCE); return(ValueRange.Of(1, max)); } } return(Chronology.Range(f)); } throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return(field.RangeRefinedBy(this)); }
public TemporalAccessorAnonymousInnerClassHelper(TemporalAccessor temporal, Chronology effectiveChrono, ZoneId effectiveZone, ChronoLocalDate effectiveDate) { this.Temporal = temporal; this.EffectiveChrono = effectiveChrono; this.EffectiveZone = effectiveZone; this.EffectiveDate = effectiveDate; }
/// <summary> /// Creates an instance. /// </summary> internal ChronoPeriodImpl(Chronology chrono, int years, int months, int days) { Objects.RequireNonNull(chrono, "chrono"); this.Chrono = chrono; this.Years = years; this.Months = months; this.Days = days; }
/// <summary> /// Adjusts the specified temporal object to have this month-day. /// <para> /// This returns a temporal object of the same observable type as the input /// with the month and day-of-month changed to be the same as this. /// </para> /// <para> /// The adjustment is equivalent to using <seealso cref="Temporal#with(TemporalField, long)"/> /// twice, passing <seealso cref="ChronoField#MONTH_OF_YEAR"/> and /// <seealso cref="ChronoField#DAY_OF_MONTH"/> as the fields. /// If the specified temporal object does not use the ISO calendar system then /// a {@code DateTimeException} is thrown. /// </para> /// <para> /// In most cases, it is clearer to reverse the calling pattern by using /// <seealso cref="Temporal#with(TemporalAdjuster)"/>: /// <pre> /// // these two lines are equivalent, but the second approach is recommended /// temporal = thisMonthDay.adjustInto(temporal); /// temporal = temporal.with(thisMonthDay); /// </pre> /// </para> /// <para> /// This instance is immutable and unaffected by this method call. /// /// </para> /// </summary> /// <param name="temporal"> the target object to be adjusted, not null </param> /// <returns> the adjusted object, not null </returns> /// <exception cref="DateTimeException"> if unable to make the adjustment </exception> /// <exception cref="ArithmeticException"> if numeric overflow occurs </exception> public Temporal AdjustInto(Temporal temporal) { if (Chronology.from(temporal).Equals(IsoChronology.INSTANCE) == false) { throw new DateTimeException("Adjustment only supported on ISO date-time"); } temporal = temporal.With(MONTH_OF_YEAR, Month_Renamed); return(temporal.With(DAY_OF_MONTH, System.Math.Min(temporal.range(DAY_OF_MONTH).Maximum, Day))); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: static ChronoPeriodImpl readExternal(java.io.DataInput in) throws java.io.IOException internal static ChronoPeriodImpl ReadExternal(DataInput @in) { Chronology chrono = Chronology.of(@in.ReadUTF()); int years = @in.ReadInt(); int months = @in.ReadInt(); int days = @in.ReadInt(); return(new ChronoPeriodImpl(chrono, years, months, days)); }
/// <summary> /// Validates that the temporal has the correct chronology. /// </summary> private void ValidateChrono(TemporalAccessor temporal) { Objects.RequireNonNull(temporal, "temporal"); Chronology temporalChrono = temporal.query(TemporalQueries.Chronology()); if (temporalChrono != null && Chrono.Equals(temporalChrono) == ChronoPeriod_Fields.False) { throw new DateTimeException("Chronology mismatch, expected: " + Chrono.Id + ", actual: " + temporalChrono.Id); } }
/// <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 long Until(Temporal endExclusive, TemporalUnit unit) { Objects.RequireNonNull(endExclusive, "endExclusive"); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") ChronoLocalDateTime<D> end = (ChronoLocalDateTime<D>) getChronology().localDateTime(endExclusive); ChronoLocalDateTime <D> end = (ChronoLocalDateTime <D>)Chronology.localDateTime(endExclusive); if (unit is ChronoUnit) { if (unit.TimeBased) { long amount = end.getLong(EPOCH_DAY) - Date.GetLong(EPOCH_DAY); switch ((ChronoUnit)unit) { case NANOS: amount = Math.MultiplyExact(amount, NANOS_PER_DAY); break; case MICROS: amount = Math.MultiplyExact(amount, MICROS_PER_DAY); break; case MILLIS: amount = Math.MultiplyExact(amount, MILLIS_PER_DAY); break; case SECONDS: amount = Math.MultiplyExact(amount, SECONDS_PER_DAY); break; case MINUTES: amount = Math.MultiplyExact(amount, MINUTES_PER_DAY); break; case HOURS: amount = Math.MultiplyExact(amount, HOURS_PER_DAY); break; case HALF_DAYS: amount = Math.MultiplyExact(amount, 2); break; } return(Math.AddExact(amount, Time.Until(end.ToLocalTime(), unit))); } ChronoLocalDate endDate = end.ToLocalDate(); if (end.ToLocalTime().IsBefore(Time)) { endDate = endDate.minus(1, ChronoUnit.DAYS); } return(Date.Until(endDate, unit)); } Objects.RequireNonNull(unit, "unit"); return(unit.Between(this, end)); }
/// <summary> /// Gets the text for the specified chrono, field, locale and style /// for the purpose of formatting. /// <para> /// The text associated with the value is returned. /// The null return value should be used if there is no applicable text, or /// if the text would be a numeric representation of the value. /// /// </para> /// </summary> /// <param name="chrono"> the Chronology to get text for, not null </param> /// <param name="field"> the field to get text for, not null </param> /// <param name="value"> the field value to get text for, not null </param> /// <param name="style"> the style to get text for, not null </param> /// <param name="locale"> the locale to get text for, not null </param> /// <returns> the text for the field value, null if no text found </returns> public virtual String GetText(Chronology chrono, TemporalField field, long value, TextStyle style, Locale locale) { if (chrono == IsoChronology.INSTANCE || !(field is ChronoField)) { return(GetText(field, value, style, locale)); } int fieldIndex; int fieldValue; if (field == ERA) { fieldIndex = DateTime.ERA; if (chrono == JapaneseChronology.INSTANCE) { if (value == -999) { fieldValue = 0; } else { fieldValue = (int)value + 2; } } else { fieldValue = (int)value; } } else if (field == MONTH_OF_YEAR) { fieldIndex = DateTime.MONTH; fieldValue = (int)value - 1; } else if (field == DAY_OF_WEEK) { fieldIndex = DateTime.DAY_OF_WEEK; fieldValue = (int)value + 1; if (fieldValue > 7) { fieldValue = DayOfWeek.Sunday; } } else if (field == AMPM_OF_DAY) { fieldIndex = DateTime.AM_PM; fieldValue = (int)value; } else { return(null); } return(CalendarDataUtility.retrieveJavaTimeFieldValueName(chrono.CalendarType, fieldIndex, fieldValue, style.toCalendarStyle(), locale)); }
/// <summary> /// Obtains an instance from an instant using the specified time-zone. /// </summary> /// <param name="chrono"> the chronology, not null </param> /// <param name="instant"> the instant, not null </param> /// <param name="zone"> the zone identifier, not null </param> /// <returns> the zoned date-time, not null </returns> //JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET: //ORIGINAL LINE: static ChronoZonedDateTimeImpl<?> ofInstant(Chronology ChronoZonedDateTime_Fields.chrono, java.time.Instant instant, java.time.ZoneId zone) internal static ChronoZonedDateTimeImpl<?> OfInstant(Chronology ChronoZonedDateTime_Fields, Instant instant, ZoneId zone) { ZoneRules rules = zone.Rules; ZoneOffset offset = rules.GetOffset(instant); Objects.RequireNonNull(offset, "offset"); // protect against bad ZoneRules LocalDateTime ldt = LocalDateTime.OfEpochSecond(instant.EpochSecond, instant.Nano, offset); //JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET: //ORIGINAL LINE: ChronoLocalDateTimeImpl<?> cldt = (ChronoLocalDateTimeImpl<?>)ChronoZonedDateTime_Fields.chrono.localDateTime(ldt); ChronoLocalDateTimeImpl<?> cldt = (ChronoLocalDateTimeImpl<?>)ChronoZonedDateTime_Fields.Chrono.localDateTime(ldt); return new ChronoZonedDateTimeImpl<>(cldt, offset, zone); }
//----------------------------------------------------------------------- public override long Until(Temporal endExclusive, TemporalUnit unit) { Objects.RequireNonNull(endExclusive, "endExclusive"); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") ChronoZonedDateTime<D> end = (ChronoZonedDateTime<D>) getChronology().zonedDateTime(endExclusive); ChronoZonedDateTime<D> end = (ChronoZonedDateTime<D>) Chronology.zonedDateTime(endExclusive); if (unit is ChronoUnit) { end = end.WithZoneSameInstant(Offset_Renamed); return DateTime.Until(end.ToLocalDateTime(), unit); } Objects.RequireNonNull(unit, "unit"); return unit.Between(this, end); }
//----------------------------------------------------------------------- /// <summary> /// Obtains an instance of {@code MonthDay} from a temporal object. /// <para> /// This obtains a month-day based on the specified temporal. /// A {@code TemporalAccessor} represents an arbitrary set of date and time information, /// which this factory converts to an instance of {@code MonthDay}. /// </para> /// <para> /// The conversion extracts the <seealso cref="ChronoField#MONTH_OF_YEAR MONTH_OF_YEAR"/> and /// <seealso cref="ChronoField#DAY_OF_MONTH DAY_OF_MONTH"/> fields. /// The extraction is only permitted if the temporal object has an ISO /// chronology, or can be converted to a {@code LocalDate}. /// </para> /// <para> /// This method matches the signature of the functional interface <seealso cref="TemporalQuery"/> /// allowing it to be used as a query via method reference, {@code MonthDay::from}. /// /// </para> /// </summary> /// <param name="temporal"> the temporal object to convert, not null </param> /// <returns> the month-day, not null </returns> /// <exception cref="DateTimeException"> if unable to convert to a {@code MonthDay} </exception> public static MonthDay From(TemporalAccessor temporal) { if (temporal is MonthDay) { return((MonthDay)temporal); } try { if (IsoChronology.INSTANCE.Equals(Chronology.from(temporal)) == false) { temporal = LocalDate.From(temporal); } return(Of(temporal.get(MONTH_OF_YEAR), temporal.get(DAY_OF_MONTH))); } catch (DateTimeException ex) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: throw new DateTimeException("Unable to obtain MonthDay from TemporalAccessor: " + temporal + " of type " + temporal.GetType().FullName, ex); } }
//----------------------------------------------------------------------- public MinguoDate With(TemporalField field, long newValue) { if (field is ChronoField) { ChronoField f = (ChronoField)field; if (GetLong(f) == newValue) { return(this); } switch (f) { case PROLEPTIC_MONTH: Chronology.Range(f).CheckValidValue(newValue, f); return(PlusMonths(newValue - ProlepticMonth)); case YEAR_OF_ERA: case YEAR: case ERA: { int nvalue = Chronology.Range(f).CheckValidIntValue(newValue, f); switch (f) { case YEAR_OF_ERA: return(With(IsoDate.WithYear(ProlepticYear >= 1 ? nvalue + YEARS_DIFFERENCE : (1 - nvalue) + YEARS_DIFFERENCE))); case YEAR: return(With(IsoDate.WithYear(nvalue + YEARS_DIFFERENCE))); case ERA: return(With(IsoDate.WithYear((1 - ProlepticYear) + YEARS_DIFFERENCE))); } } break; } return(With(IsoDate.With(field, newValue))); } return(base.With(field, newValue)); }
public ChronoPeriod Until(ChronoLocalDate endDate) { // TODO: untested HijrahDate end = Chronology.Date(endDate); long totalMonths = (end.ProlepticYear - this.ProlepticYear) * 12 + (end.MonthOfYear - this.MonthOfYear); // safe int days = end.DayOfMonth - this.DayOfMonth; if (totalMonths > 0 && days < 0) { totalMonths--; HijrahDate calcDate = this.PlusMonths(totalMonths); days = (int)(end.ToEpochDay() - calcDate.ToEpochDay()); // safe } else if (totalMonths < 0 && days > 0) { totalMonths++; days -= end.LengthOfMonth(); } long years = totalMonths / 12; // safe int months = (int)(totalMonths % 12); // safe return(Chronology.period(Math.ToIntExact(years), months, days)); }
//----------------------------------------------------------------------- public JapaneseDate With(TemporalField field, long newValue) { if (field is ChronoField) { ChronoField f = (ChronoField)field; if (GetLong(f) == newValue) // getLong() validates for supported fields { return(this); } switch (f) { case YEAR_OF_ERA: case YEAR: case ERA: { int nvalue = Chronology.Range(f).CheckValidIntValue(newValue, f); switch (f) { case YEAR_OF_ERA: return(this.WithYear(nvalue)); case YEAR: return(With(IsoDate.WithYear(nvalue))); case ERA: { return(this.WithYear(JapaneseEra.Of(nvalue), YearOfEra)); } } } break; } // YEAR, PROLEPTIC_MONTH and others are same as ISO return(With(IsoDate.With(field, newValue))); } return(base.With(field, newValue)); }
public ChronoPeriod Until(ChronoLocalDate endDate) { Period period = IsoDate.Until(endDate); return(Chronology.period(period.Years, period.Months, period.Days)); }
//------------------------------------------------------------------------- /// <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); }
public async Task <ServiceResult> EditThirdRound(int gameId, ThirdRoundEditViewModel model) { var game = await GetGameByPlayerRoles(gameId, PlayerRole.Creator); if (!game.IsSuccess) { return(Error(game.ErrorMessage)); } ThirdRound thirdRound = game.Data.ThirdRound; if (thirdRound == null) { thirdRound = new ThirdRound(); game.Data.ThirdRound = thirdRound; } //if (firstRound.QuestionCosts != null) // context.IntellectualQuestionCosts.RemoveRange(firstRound.QuestionCosts); if (thirdRound.Id != 0) { context.ThirdRounds.Remove(thirdRound); await context.SaveChangesAsync(); } //firstRound.QuestionCosts = model.QuestionCosts.Select(x => //{ // var cost = new IntellectualQuestionCost { Index = index, Value = x }; // index++; // return cost; //}).ToList(); thirdRound.Associations = model.Associations.Select(x => { var index = 0; return(new Association { Word = x.Word, AssociationVariants = x.AssociationVariants.Select(u => { var variant = new AssociationVariant { Index = index, Value = u }; index++; return variant; }).ToList() }); }).ToList(); thirdRound.Chronologies = new List <Chronology>(); foreach (var chronologyModel in model.Chronologies) { var chronology = new Chronology { ChronologyItems = new List <ChronologyItem>() }; var index = 0; foreach (var chronologyItem in chronologyModel.ChronologyItems) { var file = await fileService.SaveFile(chronologyItem.File); if (file.IsSuccess) { chronology.ChronologyItems.Add(new ChronologyItem { FileId = file.Data.Id, Value = chronologyItem.Value, Index = index }); index++; } } thirdRound.Chronologies.Add(chronology); } thirdRound.MelodyGuesses = new List <MelodyGuess>(); foreach (var melodyGuessEdit in model.MelodyGuesses) { var index = 0; var file = await fileService.SaveFile(melodyGuessEdit.File); if (file.IsSuccess) { var guess = new MelodyGuess { MelodyGuessVariants = new List <MelodyGuessVariant>(), FileId = file.Data.Id }; foreach (var variant in melodyGuessEdit.MelodyGuessVariants) { guess.MelodyGuessVariants.Add(new MelodyGuessVariant { Index = index, Value = variant }); index++; } thirdRound.MelodyGuesses.Add(guess); } } await context.SaveChangesAsync(); return(Success()); }
/// <summary> /// Gets an iterator of text to field for the specified chrono, field, locale and style /// for the purpose of parsing. /// <para> /// The iterator must be returned in order from the longest text to the shortest. /// </para> /// <para> /// The null return value should be used if there is no applicable parsable text, or /// if the text would be a numeric representation of the value. /// Text can only be parsed if all the values for that field-style-locale combination are unique. /// /// </para> /// </summary> /// <param name="chrono"> the Chronology to get text for, not null </param> /// <param name="field"> the field to get text for, not null </param> /// <param name="style"> the style to get text for, null for all parsable text </param> /// <param name="locale"> the locale to get text for, not null </param> /// <returns> the iterator of text to field pairs, in order from longest text to shortest text, /// null if the field or style is not parsable </returns> public virtual IEnumerator <Map_Entry <String, Long> > GetTextIterator(Chronology chrono, TemporalField field, TextStyle style, Locale locale) { if (chrono == IsoChronology.INSTANCE || !(field is ChronoField)) { return(GetTextIterator(field, style, locale)); } int fieldIndex; switch ((ChronoField)field) { case ERA: fieldIndex = DateTime.ERA; break; case MONTH_OF_YEAR: fieldIndex = DateTime.MONTH; break; case DAY_OF_WEEK: fieldIndex = DateTime.DAY_OF_WEEK; break; case AMPM_OF_DAY: fieldIndex = DateTime.AM_PM; break; default: return(null); } int calendarStyle = (style == null) ? DateTime.ALL_STYLES : style.toCalendarStyle(); IDictionary <String, Integer> map = CalendarDataUtility.retrieveJavaTimeFieldValueNames(chrono.CalendarType, fieldIndex, calendarStyle, locale); if (map == null) { return(null); } IList <Map_Entry <String, Long> > list = new List <Map_Entry <String, Long> >(map.Count); switch (fieldIndex) { case DateTime.ERA: foreach (Map_Entry <String, Integer> entry in map) { int era = entry.Value; if (chrono == JapaneseChronology.INSTANCE) { if (era == 0) { era = -999; } else { era -= 2; } } list.Add(CreateEntry(entry.Key, (long)era)); } break; case DateTime.MONTH: foreach (Map_Entry <String, Integer> entry in map) { list.Add(CreateEntry(entry.Key, (long)(entry.Value + 1))); } break; case DateTime.DAY_OF_WEEK: foreach (Map_Entry <String, Integer> entry in map) { list.Add(CreateEntry(entry.Key, (long)ToWeekDay(entry.Value))); } break; default: foreach (Map_Entry <String, Integer> entry in map) { list.Add(CreateEntry(entry.Key, (long)entry.Value)); } break; } return(list.GetEnumerator()); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET: //ORIGINAL LINE: private static java.time.temporal.TemporalAccessor adjust(final java.time.temporal.TemporalAccessor temporal, DateTimeFormatter formatter) private static TemporalAccessor Adjust(TemporalAccessor temporal, DateTimeFormatter formatter) { // normal case first (early return is an optimization) Chronology overrideChrono = formatter.Chronology; ZoneId overrideZone = formatter.Zone; if (overrideChrono == null && overrideZone == null) { return(temporal); } // ensure minimal change (early return is an optimization) Chronology temporalChrono = temporal.query(TemporalQueries.Chronology()); ZoneId temporalZone = temporal.query(TemporalQueries.ZoneId()); if (Objects.Equals(overrideChrono, temporalChrono)) { overrideChrono = null; } if (Objects.Equals(overrideZone, temporalZone)) { overrideZone = null; } if (overrideChrono == null && overrideZone == null) { return(temporal); } // make adjustment //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.time.chrono.Chronology effectiveChrono = (overrideChrono != null ? overrideChrono : temporalChrono); Chronology effectiveChrono = (overrideChrono != null ? overrideChrono : temporalChrono); if (overrideZone != null) { // if have zone and instant, calculation is simple, defaulting chrono if necessary if (temporal.IsSupported(INSTANT_SECONDS)) { Chronology chrono = (effectiveChrono != null ? effectiveChrono : IsoChronology.INSTANCE); return(chrono.zonedDateTime(Instant.From(temporal), overrideZone)); } // block changing zone on OffsetTime, and similar problem cases if (overrideZone.Normalized() is ZoneOffset && temporal.IsSupported(OFFSET_SECONDS) && temporal.get(OFFSET_SECONDS) != overrideZone.Rules.GetOffset(Instant.EPOCH).TotalSeconds) { throw new DateTimeException("Unable to apply override zone '" + overrideZone + "' because the temporal object being formatted has a different offset but" + " does not represent an instant: " + temporal); } } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.time.ZoneId effectiveZone = (overrideZone != null ? overrideZone : temporalZone); ZoneId effectiveZone = (overrideZone != null ? overrideZone : temporalZone); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.time.chrono.ChronoLocalDate effectiveDate; ChronoLocalDate effectiveDate; if (overrideChrono != null) { if (temporal.IsSupported(EPOCH_DAY)) { effectiveDate = effectiveChrono.Date(temporal); } else { // check for date fields other than epoch-day, ignoring case of converting null to ISO if (!(overrideChrono == IsoChronology.INSTANCE && temporalChrono == null)) { foreach (ChronoField f in ChronoField.values()) { if (f.DateBased && temporal.IsSupported(f)) { throw new DateTimeException("Unable to apply override chronology '" + overrideChrono + "' because the temporal object being formatted contains date fields but" + " does not represent a whole date: " + temporal); } } } effectiveDate = null; } } else { effectiveDate = null; } // combine available data // this is a non-standard temporal that is almost a pure delegate // this better handles map-like underlying temporal instances return(new TemporalAccessorAnonymousInnerClassHelper(temporal, effectiveChrono, effectiveZone, effectiveDate)); }