Reputation: 2126
I have defined insert method for my table in android application as follow :
public long CreateBirthDay(long id,Date _date)
{
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_ID, id);
initialValues.put(KEY_Date, dateFormat.format(_date));
return mDb.insert(DATABASE_TABLE, null, initialValues);
}
But I dont know how to get date from cursor. I mean I cant complete the below code:
bc.SetID(mCursor.getLong(mCursor.getColumnIndex(KEY_ID)));
bc.SetDate(?);
Regards.
Upvotes: 1
Views: 4518
Reputation: 9791
bc.SetDate(dateFormat.parse(mCursor.getString(mCursor.getColumnIndex(KEY_Date))));
Upvotes: 3
Reputation: 372
insert datetime as numeric using following function.
long time=datetime.gettime();
agagnin use the Date date =new Date(cursor coloumn index) to get the date object.
Upvotes: 0