Code example for GregorianCalendar

Methods: setTimeInMillis

0
    private Task getTaskFromCursor(Cursor cursor) {
        Task task = new Task();
        task.setId(cursor.getInt(ID_COLUMN));
        task.setName(cursor.getString(NAME_COLUMN));
         
        GregorianCalendar date = new GregorianCalendar();
        date.setTimeInMillis(cursor.getLong(DATE_COLUMN));
        task.setDateDue(date);
         
        return task;
    } 
     
    public Task addTask(Task task) {
        /* Perform the insertion */ 
        ContentValues rowValues = getContentValuesFromTask(task);
        mDb.insert(TABLE_NAME, null, rowValues);
         
        /* Find the row with the highest ID */ 
        Cursor cursor = mDb.query(TABLE_NAME, new String[] {ID_KEY, NAME_KEY, DATE_KEY}, null, null, null, null, ID_KEY + " DESC", "1");
        cursor.moveToFirst();
        return getTaskFromCursor(cursor);