当我在我的数据库中插入一条记录时,我想输入它插入时的日期时间戳,这样我就可以对来自Date Picker
. 这就是我在插入时获取时间戳的方式
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
int year = cal.get(Calendar.YEAR);
int day = cal.get(Calendar.DAY_OF_MONTH);
int month = cal.get(Calendar.MONTH);
cal.set(year, month, day);
long mDate = cal.getTimeInMillis();
mDate 是插入的内容
然后当我想在该日期运行项目查询时,我会这样做
public DateList(Calendar date){ //constructor
dt = date.getTimeInMillis();
}
装载机
@Override
public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
return new CursorLoader(getActivity(),Games.GAMES_URI,new String[] {Games.GAMES_ID},Games.GAMES_DATE + "=" +dt ,
null,null);
}
但是从date picker
挑选正确的日期时,从中插入的时间戳不匹配,为什么不呢?