[英]Azure String was not recognized as a valid DateTime
有趣的是,下面的代碼可在我們的內部環境中運行,但不能在天藍色的Web角色中運行。
有人能指出我正確的方向嗎?
我們從第三方獲取日期和時間作為字符串,並使用下面的邏輯進行解析。
string givenDate="21/06/2013";
string givenTime="7:35 PM";
var givenDateTime = DateTime.Parse(givenDate + " " + givenTime, CultureInfo.InvariantCulture);
上面的代碼在Azure中拋出以下異常:
Exception: System.FormatException
Message: String was not recognized as a valid DateTime.
不變文化使用美國的月/日/年格式。
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx
“ d”標准格式說明符表示由特定區域性的DateTimeFormatInfo.ShortDatePattern屬性定義的自定義日期和時間格式字符串。 例如, 不變區域性的ShortDatePattern屬性返回的自定義格式字符串為“ MM / dd / yyyy”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.