You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public string Name { get; set; }
public DateTime CreateTime { get; set; }
}
var test = new Test
{
Id = 1,
Name = "Test",
CreateTime = DateTime.Now
};
var s1 = test.ToJson(NetJSONDateFormat.Default);
var s2 = test.ToJson(NetJSONDateFormat.EpochTime);
var s3 = test.ToJson(NetJSONDateFormat.ISO);
var s4 = test.ToJson(NetJSONDateFormat.JsonNetISO);
var s5 = test.ToJson2(NetJSONDateFormat.Default);
var s6 = test.ToJson2(NetJSONDateFormat.EpochTime);
var s7 = test.ToJson2(NetJSONDateFormat.ISO);
var s8 = test.ToJson2(NetJSONDateFormat.JsonNetISO);
Result:
s1 = s2 = s3 = s4 = ""
s5 = s6 = s7 = s8
if datetime type format "yyyy-MM-dd hh:mm:ss"
please can you tell me how to operate?
@rpgmaker Is quite common for users running into a DateTime format like "yyyy-MM-dd hh:mm:ss". Is it possible to make the ISO format less strict by allowing the "T" in the pattern "yyyy-MM-dd'T'hh:mm:ss' to be another character?
I suppose I can add an extension to support custom format instead of substitution of character. Though it will be easier to substitute it, don't want to create a custom ISO with character replacement only.
I have added DateStringFormat to the NetJSONSettings object. You can use it to specific how you want the formatting of string to be done and it will ignore the other options related to date. Note: this option uses the default .net date formatting method and will be slower than using the predefined option (This statement allow applies if you are worried about micro-perf of your application :) )
Activity
rpgmaker commentedon Dec 13, 2016
A custom format such as yours is not supported. I will have to add it. The closest is ISO format.
rpgmaker commentedon Dec 14, 2016
Did I answer your question?
wmjordan commentedon Dec 14, 2016
@rpgmaker Is quite common for users running into a
DateTimeformat like "yyyy-MM-dd hh:mm:ss". Is it possible to make the ISO format less strict by allowing the "T" in the pattern "yyyy-MM-dd'T'hh:mm:ss' to be another character?rpgmaker commentedon Dec 14, 2016
I suppose I can add an extension to support custom format instead of substitution of character. Though it will be easier to substitute it, don't want to create a custom ISO with character replacement only.
Thanks,
rpgmaker commentedon Dec 26, 2016
I have added DateStringFormat to the NetJSONSettings object. You can use it to specific how you want the formatting of string to be done and it will ignore the other options related to date. Note: this option uses the default .net date formatting method and will be slower than using the predefined option (This statement allow applies if you are worried about micro-perf of your application :) )