JSON Date form: "/date (1242357713797+0800)/", below we will use the following C # method to convert him to a datetime type:
<summary>
The Json date format is converted to a. Net datetime type
</summary>
<param name= "Jsondate" >json date, for example:/date (928120800000+0800)/</param>
<returns></returns>
public static DateTime Jsontodatetime (String jsondate)
{
String value = jsondate.substring (6, jsondate.length-8);
DateTimeKind kind = DATETIMEKIND.UTC;
int index = value. IndexOf (' + ', 1);
if (index = =-1)
index = value. IndexOf ('-', 1);
if (Index! =-1)
{
kind = datetimekind.local;
Value = value. Substring (0, index);
}
Long javascriptticks = long. Parse (value, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture);
Long initialjavascriptdateticks = (New DateTime (1970, 1, 1, 0, 0, 0, DATETIMEKIND.UTC)). Ticks;
DateTime utcdatetime = new DateTime ((Javascriptticks * 10000) + initialjavascriptdateticks, DATETIMEKIND.UTC);
datetime datetime;
Switch (kind)
{
Case Datetimekind.unspecified:
DateTime = Datetime.specifykind (Utcdatetime.tolocaltime (), datetimekind.unspecified);
Break
Case Datetimekind.local:
DateTime = Utcdatetime.tolocaltime ();
Break
Default
DateTime = UtcDateTime;
Break
}
return dateTime;
}