title: How to format NodaTime date string globally in ASP.NET Core 2.1?
body: <p>Currently, I am trying to use the <code>JsonFormatters</code> for serializing a string in <code>ISO 8601</code> spec. format in my startup config, but could not get it to work.</p>
  
  <p>My Startup Config is as follows:</p>
  
  <pre><code>services.AddMvcCore(
      (options) =&gt; {
          options.SslPort = 44321;
          options.Filters.Add(new RequireHttpsAttribute());
      }
  )
  .AddJsonFormatters(jsonSerializerSettings =&gt; {
      jsonSerializerSettings.DateParseHandling = DateParseHandling.None;
      jsonSerializerSettings.DateFormatString = "yyyy-MM-ddTHH:mm:ss.fffZ";
  })
  .AddApiExplorer()
  .AddJsonOptions(options =&gt; {
      options.AllowInputFormatterExceptionMessages = false;
      options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
  })
  .SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
  .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
  .AddDataAnnotationsLocalization();
  </code></pre>
  
  <p>I also tried <a href="https://github.com/AnthonyCarl/NodaTime.Serialization.ServiceStackText/blob/master/README.md" rel="nofollow noreferrer">ServiceStackText</a> which is mentioned in the <a href="https://nodatime.org/1.2.x/userguide/serialization" rel="nofollow noreferrer">documentation</a>, but that did not work either.</p>
  
  <pre><code> NodaSerializerDefinitions.LocalTimeSerializer.ConfigureSerializer();
   DateTimeZoneProviders.Tzdb
       .CreateDefaultSerializersForNodaTime()
       .ConfigureSerializersForNodaTime();
  </code></pre>
  
  <p>I keep getting the following format,</p>
  
  <p>i.e. for <code>LocalDate</code> serialization:</p>
  
  <pre><code>{
      "patientDob": "Thursday, June 15, 2017",
  }
  </code></pre>
  
  <p>How can I configure the string <code>ISO 8601</code> spec. formatting for <code>NodaTime</code> date types globally?</p>
  
  <p>my model,</p>
  
  <pre><code>{
      public LocalDate patientDob { get; set; }
  }
  </code></pre>
  
  <p>and my view model/API resource:</p>
  
  <pre><code>{
      public string patientDob { get; set; }
  }
  </code></pre>