You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
621 B
19 lines
621 B
using System;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Win.Utils
|
|
{
|
|
public class DateTimeConverterUsingDateTimeParse : JsonConverter<DateTime>
|
|
{
|
|
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
{
|
|
return DateTime.Parse(reader.GetString() ?? string.Empty);
|
|
}
|
|
|
|
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
|
|
{
|
|
writer.WriteStringValue(value.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
}
|
|
}
|
|
}
|