Skip to content

Class DateConverter ​

Namespace: Tool.Utils
Assembly: Tool.Net.dll

Json 标准或自定义日期和时间格式字符串。

csharp
public class DateConverter : JsonConverter<DateTime>

Inheritance ​

object ← JsonConverter ← JsonConverter<DateTime> ← DateConverter

Inherited Members ​

JsonConverter<DateTime>.CanConvert(Type), JsonConverter<DateTime>.Read(ref Utf8JsonReader, Type, JsonSerializerOptions), JsonConverter<DateTime>.Write(Utf8JsonWriter, DateTime, JsonSerializerOptions), JsonConverter<DateTime>.HandleNull, JsonConverter.CanConvert(Type), object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Extension Methods ​

ObjectExtension.Add<T>(object, object, object), ObjectExtension.CopyEntity(object, object, params string[]), ObjectExtension.EntityToJson(object), ObjectExtension.EntityToJson(object, bool), ObjectExtension.EntityToJson(object, bool, string), DictionaryExtension.GetDictionary(object), TypeExtension.GetFieldKey(object, string, out bool), TypeExtension.GetFieldKey<T>(object, string, out bool), TypeExtension.GetFieldKey(object, Type, string, out bool), ObjectExtension.GetIntPtr(object), ObjectExtension.GetIntPtrInt(object), TypeExtension.GetPropertieFind(object, string, bool), TypeExtension.GetProperties(object), TypeExtension.GetPropertyKey(object, string, out bool), TypeExtension.GetPropertyKey<T>(object, string, out bool), TypeExtension.GetPropertyKey(object, Type, string, out bool), TypeExtension.GetValue(object, PropertyDescriptor), TypeExtension.GetValue(object, string, bool), TypeExtension.GetValue(object, string), ObjectExtension.Read<T>(object, object, int, int), ObjectExtension.Read<T>(object, int, object, int, int), DictionaryExtension.SetDictionary(object, IDictionary<string, object>), TypeExtension.SetFieldKey(object, string, object), TypeExtension.SetFieldKey<T>(object, string, object), TypeExtension.SetFieldKey(object, Type, string, object), TypeExtension.SetPropertyKey(object, string, object), TypeExtension.SetPropertyKey<T>(object, string, object), TypeExtension.SetPropertyKey(object, Type, string, object), TypeExtension.SetValue(object, PropertyDescriptor, object), TypeExtension.SetValue(object, string, object, bool), TypeExtension.SetValue(object, string, object), ObjectExtension.ToBase64String(object), ObjectExtension.ToBytes(object), ObjectExtension.ToBytes(object, out Type), DictionaryExtension.ToDictionary(object), DictionaryExtension.ToDictionary<T>(object), DictionaryExtension.ToIDictionary(object), DictionaryExtension.ToIDictionary<T>(object), ObjectExtension.ToJson(object), ObjectExtension.ToJson(object, JsonSerializerOptions), ObjectExtension.ToJsonWeb(object), ObjectExtension.ToJsonWeb(object, Action<JsonSerializerOptions>), ObjectExtension.ToTryVar<T>(object, T), ObjectExtension.ToVar<T>(object), ObjectExtension.ToVar(object, Type, bool), ObjectExtension.ToVar(object, string), ObjectExtension.ToXml(object)

Remarks ​

代码由逆血提供支持

Constructors ​

DateConverter(string) ​

注册 时间格式实例

csharp
public DateConverter(string format)

Parameters ​

format string

Properties ​

Format ​

标准或自定义日期和时间格式字符串。

csharp
public string Format { get; }

Property Value ​

string

Methods ​

CanConvert(Type) ​

验证是否支持类型

csharp
public override bool CanConvert(Type objectType)

Parameters ​

objectType Type

Returns ​

bool

Read(ref Utf8JsonReader, Type, JsonSerializerOptions) ​

将字符串转换成原数据

csharp
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

Parameters ​

reader Utf8JsonReader

typeToConvert Type

options JsonSerializerOptions

Returns ​

DateTime

Write(Utf8JsonWriter, DateTime, JsonSerializerOptions) ​

将原数据转换成字符串

csharp
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)

Parameters ​

writer Utf8JsonWriter

value DateTime

options JsonSerializerOptions

基于Apache-2.0协议开源