Class DateTimeConverter
- Namespace
- Cuemon.Extensions.Text.Json.Converters
- Assembly
- Cuemon.Extensions.Text.Json.dll
Provides a DateTime converter that can be configured like the Newtonsoft.JSON equivalent.
public class DateTimeConverter : JsonConverter<DateTime>
- Inheritance
-
DateTimeConverter
- Inherited Members
- Extension Methods
Constructors
DateTimeConverter(string, CultureInfo)
Initializes a new instance of the DateTimeConverter class.
public DateTimeConverter(string format = "O", CultureInfo provider = null)
Parameters
formatstringA standard or custom date and time format string.
providerCultureInfoAn object that supplies culture-specific formatting information.
Methods
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Reads and converts the JSON to DateTime.
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
readerUtf8JsonReaderThe Utf8JsonReader to read from.
typeToConvertTypeThe Type being converted.
optionsJsonSerializerOptionsThe JsonSerializerOptions being used.
Returns
- DateTime
The converted value.
Write(Utf8JsonWriter, DateTime, JsonSerializerOptions)
Write the value as JSON.
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
Parameters
writerUtf8JsonWriterThe Utf8JsonWriter to write to.
valueDateTimeThe value to convert.
optionsJsonSerializerOptionsThe JsonSerializerOptions being used.