DateOnlyConverter.cs 752 B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.Json.Serialization;
  6. using System.Text.Json;
  7. using System.Threading.Tasks;
  8. namespace OASystem.Domain
  9. {
  10. /// <summary>
  11. /// datetime 返回日期 格式 yyyy-MM-dd
  12. /// </summary>
  13. public class DateOnlyConverter : JsonConverter<DateTime>
  14. {
  15. public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
  16. {
  17. throw new NotImplementedException();
  18. }
  19. public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
  20. {
  21. writer.WriteStringValue(value.ToString("yyyy-MM-dd"));
  22. }
  23. }
  24. }