Skip to content

Handle Date Only

fonlow edited this page Feb 5, 2022 · 1 revision

On .NET Frameworks, .NET Core and .NET 5, to handle date only, you may have 2 approaches at the application level:

  1. Use string like "2018-01-23".
  2. Use DateTime or DateTimeOffset and set the time segment to zero.

And DataTypeAttribute(DataType.Date) may be useful for UI codes coded in C#, however, the designs of JsonConverter of NewtonSoft and System.Text.Json do not care about attributes decorated on a class property, because JsonConverter deal with objects only, not properties.

Clone this wiki locally