從iPhone應用程序,我必須發送日期作爲參數到一個webservice方法,其中服務器解析邏輯用C#,.NET和JSON實現。從iphone應用程序發送日期時間到web服務
在我的iPhone應用程序,我格式化日期:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
[dateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"];
NSString *myDateString = [dateFormatter stringFromDate:SentOn];
我收到錯誤:
There was an error deserializing the object of type DashboardDataContract.Contracts.DashboardInputParams. DateTime content '2013-04-04T12:00:00Z' does not start with '/Date(' and end with ')/' as required for JSON.'.
我試圖日期的不同格式。在這方面有人能幫助我嗎?
非常好,簡單的創建一個類的方法! – user2068793 2013-04-04 11:54:08
這是否可以在所有時區使用? – Anupdas 2013-04-04 12:03:52
如果您想添加時區,您需要格式爲/ Date(xxxxxxxxxxxx + yyyy)/其中yyyy是時區,例如:/ Date(12345678954 + 0000)/ – 2013-04-04 12:06:35