24 lines
846 B
C#
24 lines
846 B
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using Volo.Abp.DependencyInjection;
|
|||
|
|
|||
|
namespace Syc.Abp.Application.Contracts.Converter
|
|||
|
{
|
|||
|
public class DateTimeNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter<DateTime>,ITransientDependency
|
|||
|
{
|
|||
|
public override DateTime ReadJson(Newtonsoft.Json.JsonReader reader, Type objectType, DateTime existingValue, bool hasExistingValue, Newtonsoft.Json.JsonSerializer serializer)
|
|||
|
{
|
|||
|
var val = reader.Value;
|
|||
|
return DateTime.Parse((string)val);
|
|||
|
}
|
|||
|
|
|||
|
public override void WriteJson(Newtonsoft.Json.JsonWriter writer, DateTime value, Newtonsoft.Json.JsonSerializer serializer)
|
|||
|
{
|
|||
|
writer.WriteValue(value.ToString("yyyy-MM-dd HH:mm:ss"));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|