我有一個字符串,其中包含日期和格式爲「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