Skip to content

JsonElement.GetDateTimeOffset Method

Definition

Namespace: Corvus.Text.Json
Assembly: Corvus.Text.Json.dll
Source: JsonElement.cs

GetDateTimeOffset()

Gets the value of the element as a DateTimeOffset.

public DateTimeOffset GetDateTimeOffset()

Returns

DateTimeOffset

The value of the element as a DateTimeOffset.

Exceptions

Exception Description
InvalidOperationException This value's ValueKind is not String.
FormatException The value cannot be represented as a DateTimeOffset.
ObjectDisposedException The parent JsonDocument has been disposed.

Remarks

This method does not create a DateTimeOffset representation of values other than JSON strings.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create and review issues and pull requests.

Open an issue