我正在尝试将用户输入的日期与今天的日期进行比较,并相应地更新数据库。这就是我正在做的..
Calendar c = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("MM-dd-yyyy");
today = df.format(c.getTime());
//===================================================================
try{
ContentValues val1 = new ContentValues();
val1.put(CPUser.Data.TASK_TYPE, "Todays Task");
getContentResolver().update(CPUser.Data.CONTENT_URI, val1, CPUser.Data.TASK_DUE_DATE + "=" +"'"+today+"'",null);
ContentValues val2 = new ContentValues();
val2.put(CPUser.Data.TASK_TYPE, "Overdue Task");
getContentResolver().update(CPUser.Data.CONTENT_URI, val2, CPUser.Data.TASK_DUE_DATE + "<" +"'"+today+"'",null);
ContentValues val3 = new ContentValues();
val3.put(CPUser.Data.TASK_TYPE, "Active Task");
getContentResolver().update(CPUser.Data.CONTENT_URI, val3, CPUser.Data.TASK_DUE_DATE + ">" +"'"+today+"'",null);
}
Catch(Exception ex)
{ }