String
データベースからミリ秒を取得してSQLite
いて、それをフォーマットされた日付に変換したいと思いますString
。基本的には機能しますが、配列で試している場合は機能しません(以下を参照)。をスローしNumberFormatException
ます。どうすればこれを修正できますか?
adapter = new SimpleCursorAdapter(this, R.layout.listrow, cursor,
new String[] { getDate(Long.parseLong(Database.KEY_DATE), "dd. MMMM yyyy hh:mm:ss") , Database.KEY_NAME },
new int[] {R.id.text1, R.id.text2}, 0);
public static String getDate(Long milliSeconds, String dateFormat){
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(milliSeconds);
return formatter.format(calendar.getTime());
}