开发者

How can I use DateTime.Parse() with point separator?

开发者 https://www.devze.com 2023-04-03 07:34 出处:网络
I would like to parse a date like this \"1.09.开发者_运维问答2011\"? Should I use the IFormatProvider?

I would like to parse a date like this "1.09.开发者_运维问答2011"? Should I use the IFormatProvider?

I know that I can try to replace the point with the replace method but i don't like the idea.


Try DateTime.ParseExact( myString, "d.MM.yyyy", CultureInfo.InvariantCulture);

EDIT

Change the format from "dd.MM.yyyy" to "d.MM.yyyy" to properly reflect Dran's input string.


DateTime.ParseExact allows you to specify a format string.

0

精彩评论

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