|
12345678910111213141516171819202122232425 |
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Newtonsoft.Json;
-
- namespace BlackRockReportFunction.Helpers
- {
- public class TimeOnlyConverter : JsonConverter<TimeOnly>
- {
- private const string Format = "hh:mm:ss";
-
- public override TimeOnly ReadJson(JsonReader reader,
- Type objectType,
- TimeOnly existingValue,
- bool hasExistingValue,
- JsonSerializer serializer) =>
- TimeOnly.ParseExact((string)reader.Value, Format, CultureInfo.InvariantCulture);
-
- public override void WriteJson(JsonWriter writer, TimeOnly value, JsonSerializer serializer) =>
- writer.WriteValue(value.ToString(Format, CultureInfo.InvariantCulture));
- }
- }
|