I am trying to apply a custom datetime format to an array of datetime values. I know you can use IsoDateTimeConverter to accomplish this for single values e.g.
class CustomDateTimeConverter : IsoDateTimeConverter
{
public CustomDateTimeConverter()
{
base.DateTimeFormat = "yyyy-MM-dd";
}
}
class ReturnObjectA
{
[JsonConverter(typeof(CustomDateTimeConverter))]
public DateTime ReturnDate { get; set;}
}
But how do apply the same thing to an array of datetimes? e.g. The following does not work.
class ReturnObjectA
{
[JsonConverter(typeof(CustomDateTimeConverter))]
public DateTime[] ReturnDate { get; set;}
}
JsonProperty is what you're looking for:
class ReturnObjectA
{
[JsonProperty(ItemConverterType = typeof(CustomDateTimeConverter))]
public DateTime[] ReturnDate { get; set; }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With