开发者

Date.TryParse for decimal converting date

I have string that contains "1.3" and I am checking with Date.TryParse method. It automatically converting 开发者_如何学运维into "1/3/2010". How to handle this?

Date.TryParse for decimal converting date

Date.TryParse for decimal converting date


Why 1.3f returns true on TryParse? Because the TryParse method take that as valid input. Probably, some of supported date formats separates token by dot. You may want to try method:

DateTime.TryParse(String, IFormatProvider, DateTimeStyles, DateTime%) and as IFormatProvider supply CultureInfo.createSpecificCulture("en-US or whatever you want").

or

DateTime.TryParseExact, which allows you to supply specific format to parse the string into a DateTime object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜