title: Specific DateTime format for System.Text.Json ASP.NET Core 3.1
body: <p>I have a datetime input with format <code>dd/MM/yyyy</code> but the datetime is wrong when I debug to the controller</p>
  <p><a href="https://i.stack.imgur.com/Gci8J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gci8J.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/m70rX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m70rX.png" alt="enter image description here" /></a></p>
  <p>what I already try is make custom converter like this:</p>
  <pre><code>public class DateTimeConverter : JsonConverter&lt;DateTime&gt;
  {
      public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
      {
          if (reader.TokenType == JsonTokenType.String)
          {
              var s = reader.GetString();
              if (DateTime.TryParseExact(s, &quot;dd/MM/yyyy&quot;, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dt))
              {
                  return dt;
              }
          }
  
          return reader.GetDateTime();
      }
  
      public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
      {
          writer.WriteStringValue(value);
      }
  }
  
  public class DateTimeNullableConverter : JsonConverter&lt;DateTime?&gt;
  {
      public override DateTime? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
      {
          var s = reader.GetString();
          if (DateTime.TryParseExact(s, &quot;dd/MM/yyyy&quot;, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dt))
          {
              return dt;
          }
          return null;
      }
  
      public override void Write(Utf8JsonWriter writer, DateTime? value, JsonSerializerOptions options)
      {
          if (value != null)
          {
              writer.WriteStringValue(value.Value);
          }
          else
          {
              writer.WriteStringValue(string.Empty);
          }
      }
  }
  </code></pre>
  <p>and register it to <code>Startup.cs</code> like this</p>
  <pre><code>services.AddControllersWithViews()
      .AddRazorRuntimeCompilation()
      .AddJsonOptions(options =&gt;
      {
          options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
          options.JsonSerializerOptions.Converters.Add(new DateTimeConverter());
          options.JsonSerializerOptions.Converters.Add(new DateTimeNullableConverter());
          options.JsonSerializerOptions.PropertyNamingPolicy = null;
      });
  </code></pre>
  <p>and still no result.</p>
  <p>But if I change my computer date format to <code>dd/MM/yyyy</code> the code is work fine
  <a href="https://i.stack.imgur.com/eMkZv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eMkZv.png" alt="enter image description here" /></a></p>
  <p>is there anything wrong? thanks in advance</p>