我有一个字符串,其中包含日期和格式为“MMMyy”。如何做到这一点?
样品:C#日期时间解析短字符串(“MMMyy”)
string date = "MAY09";
DateTime a = DateTime.Parse("MAY09"); //Gives "2012.05.09 00:00:00"
DateTime b = DateTime.ParseExact("MAY09", "MMMyy", null); //Gives error
DateTime c = Convert.ToDateTime("MAY09"); //Gives "2012.05.09 00:00:00"
I need "2009-05-01"
'null'将意味着当前的文化你尝试与InvariantCulture的? – V4Vendetta 2012-07-26 06:41:24
是的!谢谢。 InvariantCulture做了诀窍。 – JNM 2012-07-26 06:48:07