ありがとうGiulio Piancastelli私は今、複数のライン機能を持つリストビューを持っています。今、私は2行目の日付の書式設定に問題があります。すべての日付は同じです。飼料には違いがあります。日、月、年(2011年10月27日(木))の形式で日付をフォーマットするのに役立つ人が必要です。 Android Date format in ListView
この
は が動作しないコードです:私は私の以前の日付コードを削除する場合List<Map<String, String>> data = new ArrayList<Map<String, String>>();
for (RSSItem item : feed.getAllItems()) {
Map<String, String> datum = new HashMap<String, String>(2);
datum.put("title", item.getTitle());
String dateStr = item.getPubDate();
SimpleDateFormat curFormater = new SimpleDateFormat("EEEE, MMMM dd, yyyy");
Date dateObj = new Date();
try {
dateObj = curFormater.parse(dateStr);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
SimpleDateFormat postFormater = new SimpleDateFormat("EEEE, MMMM dd, yyyy");
String newDateStr = postFormater.format(dateObj);
datum.put("date", newDateStr);
data.add(datum);
}
SimpleAdapter adapter = new SimpleAdapter(this, data,
android.R.layout.simple_list_item_2,
new String[] {"title", "date"},
new int[] {android.R.id.text1,
android.R.id.text2});
itemlist.setAdapter(adapter);
itemlist.setOnItemClickListener(this);
itemlist.setSelection(0);
それがうまく動作しますが、間違ってフォーマットされています。
このコードは、作業を行いますが、間違ってフォーマットされます。
List<Map<String, String>> data = new ArrayList<Map<String, String>>();
for (RSSItem item : feed.getAllItems()) {
Map<String, String> datum = new HashMap<String, String>(2);
datum.put("title", item.getTitle());
datum.put("date", item.getPubDate().toString());
data.add(datum);
}
SimpleAdapter adapter = new SimpleAdapter(this, data,
android.R.layout.simple_list_item_2,
new String[] {"title", "date"},
new int[] {android.R.id.text1,
android.R.id.text2});
itemlist.setAdapter(adapter);
itemlist.setOnItemClickListener(this);
itemlist.setSelection(0);
は、私は私は日、月、年(10月(木曜日)の形式で私の日付の書式を助けるために誰かを必要とします27、2011)。ありがとうございました!
したがって、基本的に12:00:00 GMTの部分を取り除きたいですか? –
日に日、月、年を読みたい。このように:2011年10月27日木曜日 –
最初のスクリーンショットで見ているものがあなたの望むものではありませんか? –