我正在android應用程序中工作,我使用c#作爲服務器和RavenDB作爲數據庫。我檢索了以下JSON數組從服務器的響應隱藏的c#日期時間格式到java日期時間格式
"GridRecords":[{
"AddedTime":"2013-07-03T19:16:02.3694","TransactId":"CTRF315687490298",
"Status":2,"OtherPartyAccountNo":"364210000001","AmountPaid":100.0,
"AmountRecieved":0.0,"ClosingBalance":674.54,"TransType":8,
"Narration":null,"AddedBy":"Trader-9787457361-Vinoth"}]
我需要在Java dd-mm-YYYY
格式,但是當我解析字符串(2013-07-03T19:16:02.3694)到Java日期時間,我得到像無法解析的異常消息。
其實我的代碼的樣子,
static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
static SimpleDateFormat currentformatter = new SimpleDateFormat(
"dd-MM-yyyy");
JSONArray ArrayData = data.getJSONArray("GridRecords");
for (int i = 0; i < ArrayData.length(); i++) {
JSONObject reportItem = ArrayData.getJSONObject(i);
Date receiptdate = Date.valueOf(currentformatter.format(formatter.parse(reportItem.getString("AddedTime").toString())));
}
[this]怎麼樣(http://msdn.microsoft.com/library/8kb3ddd4.aspx)你需要幫助嗎? – Corak
給我們實際的例外... –
...和你試過的代碼... –