-
Notifications
You must be signed in to change notification settings - Fork 446
/
Copy pathJsonLocalDateTimeConverter.cs
33 lines (29 loc) · 1.17 KB
/
JsonLocalDateTimeConverter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Globalization;
namespace WebApiClientCore.Serialization.JsonConverters
{
/// <summary>
/// 表示DateTime和DateTimeOffset的Json转换器
/// </summary>
[Obsolete("请使用JsonDateTimeConverter替代")]
public class JsonLocalDateTimeConverter : JsonDateTimeConverter
{
/// <summary>
/// 获取ISO8601格式的实例
/// </summary>
public static JsonLocalDateTimeConverter Default { get; } = new JsonLocalDateTimeConverter();
/// <summary>
/// 获取本设备的时间格式的实例
/// </summary>
public static JsonLocalDateTimeConverter LocalMachine { get; } = new JsonLocalDateTimeConverter($"{DateTimeFormatInfo.CurrentInfo.ShortDatePattern} {DateTimeFormatInfo.CurrentInfo.LongTimePattern}");
/// <summary>
/// DateTime和DateTimeOffset的Json转换器
/// </summary>
/// <param name="dateTimeFormat">日期时间格式</param>
/// <exception cref="ArgumentNullException"></exception>
public JsonLocalDateTimeConverter(string dateTimeFormat = "O")
: base(dateTimeFormat)
{
}
}
}