AddDateTimeConverter Method
Definition
- Namespace
- Cuemon.Extensions.Text.Json.Converters
- Assemblies
- Cuemon.Extensions.Text.Json.dll
AddDateTimeConverter(ICollection<JsonConverter>, string, CultureInfo)
Adds a configurable DateTime JSON converter to the list.
public static ICollection<JsonConverter> AddDateTimeConverter(this ICollection<JsonConverter> converters, string format = "O", CultureInfo provider = null)
Parameters
convertersICollection<JsonConverter>The ICollection<T> to extend.
formatstringA standard or custom date and time format string.
providerCultureInfoAn object that supplies culture-specific formatting information.
Returns
- ICollection<JsonConverter>
A reference to
convertersafter the operation has completed.
Examples
var formatter = new JsonFormatter(o => o.Settings.Converters.AddDateTimeConverter());
Remarks
If you miss the opportunity to configure DateTime format handling like you could with Newtonsoft.JSON, here is an alternative way. Default is "O" (https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings#table-of-format-specifiers).