我有一个sqlite列日期为这种格式的字符串yyyy-mm-dd,我试图用SimpleDateFormat转换它,但总是返回01-01-1970? 这是我的适配器代码:转换Sqlite列日期格式与SimpleDateFormat
adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
if (view.getId() == R.id.swimm_date)
{
int DateUSA = cursor.getInt(columnIndex);
TextView tv = (TextView)view;
DateFormat FormatDate = new SimpleDateFormat ("dd-MM-yyyy");
String DateEUR = FormatDate.format(DateUSA);
tv.setText(DateEUR);
return true;
}
int DateUSA = cur sor.getInt(columnIndex);如果你将它存储为一个字符串..你为什么要检索它作为一个int .. – dymmeh
'yyyy-MM-dd'或'dd-MM-yyyy'? –
在数据库中我已经字符串yyyy-MM-dd,我想转换为dd-MM-yyyy – lucignolo