I have a C# class which is used as a API json response. I have some properties defined as DateTimeOffset.
public DateTimeOffset Time1 { get; set; }
public DateTimeOffset Time2 { get; set; }
The client receives the format as: 2024-01-02T15:26:13+00:00
but the required format is: 2011-01-25T11:53:22.010Z
Initially, I thought of storing as string doing format conversion using ToString() but as some of the properties are used in the program for date calculation, I cannot convert all to string.
I saw online that there are attributes that can be used on DateTime but I cannot find one for DateTimeOffset.
How do I use annotation to convert the format for DateTimeOffset ?
Thanks.