簡體   English   中英

僅在Galaxy Nexus上具有ParseException

[英]ParseException only on Galaxy Nexus

我在5部不同的手機上測試了我的應用程序,但此異常僅發生在Samsung Galaxy Nexus上:

java.text.ParseException: Unparseable date: "Sun, 19 Feb 2012 14:02:43 +0100" (at offset 0)

我的輸入字符串:

<pubDate>Sun, 19 Feb 2012 14:02:43 +0100</pubDate>

我的代碼:

private String getString(Element item, String tag) {

    Element e = (Element) item.getElementsByTagName(tag).item(0);
    return e.getFirstChild().getNodeValue();
}

SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss ZZZZ");
String tmpDate = getString(item, "pubDate");
Date pubDate = new Date(System.currentTimeMillis());
pubDate = sdf.parse(tmpDate);

這是Android 4.0的問題還是我犯了一些錯誤?

另外,我的國家標志有問題。 我在UTF-8中有xml,我想在WebView中顯示它。 我有UTF-8編碼的html文件,它在除Galaxy Nexus之外的所有設備上均可正常使用-它顯示一些奇怪的字符而不是我的國家標志。

你有什么想法?

我敢打賭,Nexus默認情況下會設置其他語言環境。 嘗試使用

SimpleDateFormat(String pattern, Locale locale) 

構造函數的變體,以在日期字符串中顯式設置所需的語言環境。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM