小编its*_*end的帖子

RestSharp将Datetimes转换为UTC

我有以下问题

我正在使用RestSharp来访问我的API.但是当我发送DateTime时,它似乎转换为UTC.我发送'10 .06.1991 00:00',API得到'09 .06.1991 22:00'

那么,当我的API获取DateTime对象时,我总是需要增加2个小时?

我检查了JSON RestSharp发送给API.

public class Test
{
    public int IntProperty {get;set;}
    public string StringProperty {get;set;}
    public DateTime DateTimeProperty {get;set;}
}
Run Code Online (Sandbox Code Playgroud)

我的目标是

Test t = new Test{ IntProperty=3, StringProperty="string", DateTimeProperty=new DateTime(1991,06,10) }
Run Code Online (Sandbox Code Playgroud)

当我通过RestSharp发送对象时,我的API接收的JSON是

{
    "IntProperty":3,
    "StringProperty":"string",
    "DateTimeProperty":"09.06.1991 22:00:00"
}
Run Code Online (Sandbox Code Playgroud)

知道我能做什么吗?谢谢

c# restsharp

6
推荐指数
1
解决办法
2949
查看次数

标签 统计

c# ×1

restsharp ×1