Table of Contents

AddDateTimeConverter Method

Definition

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

converters ICollection<JsonConverter>

The ICollection<T> to extend.

format string

A standard or custom date and time format string.

provider CultureInfo

An object that supplies culture-specific formatting information.

Returns

ICollection<JsonConverter>

A reference to converters after 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).