Instant.With Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| With(ITemporalField, Int64) |
Returns a copy of this instant with the specified field set to a new value. |
| With(ITemporalAdjuster) |
Returns an adjusted copy of this instant. |
With(ITemporalField, Int64)
Returns a copy of this instant with the specified field set to a new value.
[Android.Runtime.Register("with", "(Ljava/time/temporal/TemporalField;J)Ljava/time/Instant;", "", ApiSince=26)]
public Java.Time.Temporal.ITemporal? With(Java.Time.Temporal.ITemporalField? field, long newValue);
[<Android.Runtime.Register("with", "(Ljava/time/temporal/TemporalField;J)Ljava/time/Instant;", "", ApiSince=26)>]
abstract member With : Java.Time.Temporal.ITemporalField * int64 -> Java.Time.Temporal.ITemporal
override this.With : Java.Time.Temporal.ITemporalField * int64 -> Java.Time.Temporal.ITemporal
Parameters
- field
- ITemporalField
TemporalField: the field to set in the result, not null
- newValue
- Int64
long: the new value of the field in the result
Returns
an Instant based on this with the specified field set, not null
Implements
- Attributes
Remarks
Returns a copy of this instant with the specified field set to a new value. This returns an Instant, based on this one, with the value for the specified field changed. If it is not possible to set the value, because the field is not supported or for some other reason, an exception is thrown. If the field is a ChronoField then the adjustment is implemented here. The supported fields behave as follows: NANO_OF_SECOND - Returns an Instant with the specified nano-of-second. The epoch-second will be unchanged. MICRO_OF_SECOND - Returns an Instant with the nano-of-second replaced by the specified micro-of-second multiplied by 1,000. The epoch-second will be unchanged. MILLI_OF_SECOND - Returns an Instant with the nano-of-second replaced by the specified milli-of-second multiplied by 1,000,000. The epoch-second will be unchanged. INSTANT_SECONDS - Returns an Instant with the specified epoch-second. The nano-of-second will be unchanged. In all cases, if the new value is outside the valid range of values for the field then a DateTimeException will be thrown. All other ChronoField instances will throw an UnsupportedTemporalTypeException. If the field is not a ChronoField, then the result of this method is obtained by invoking TemporalField.adjustInto(Temporal, long) passing this as the argument. In this case, the field determines whether and how to adjust the instant. This instance is immutable and unaffected by this method call.
Throws: ArithmeticException if numeric overflow occurs
Throws: DateTimeException if the field cannot be set
Throws: UnsupportedTemporalTypeException if the field is not supported
Android reference for java.time.Instant.with.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Applies to
With(ITemporalAdjuster)
Returns an adjusted copy of this instant.
[Android.Runtime.Register("with", "(Ljava/time/temporal/TemporalAdjuster;)Ljava/time/Instant;", "", ApiSince=26)]
public Java.Time.Instant? With(Java.Time.Temporal.ITemporalAdjuster? adjuster);
[<Android.Runtime.Register("with", "(Ljava/time/temporal/TemporalAdjuster;)Ljava/time/Instant;", "", ApiSince=26)>]
member this.With : Java.Time.Temporal.ITemporalAdjuster -> Java.Time.Instant
Parameters
- adjuster
- ITemporalAdjuster
TemporalAdjuster: the adjuster to use, not null
Returns
an Instant based on this with the adjustment made, not null
- Attributes
Remarks
Returns an adjusted copy of this instant. This returns an Instant, based on this one, with the instant adjusted. The adjustment takes place using the specified adjuster strategy object. Read the documentation of the adjuster to understand what adjustment will be made. The result of this method is obtained by invoking the TemporalAdjuster.adjustInto(Temporal) method on the specified adjuster passing this as the argument. This instance is immutable and unaffected by this method call.
Throws: ArithmeticException if numeric overflow occurs
Throws: DateTimeException if the adjustment cannot be made
Android reference for java.time.Instant.with.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.