現在の日付と SQLite の日付の間の週数の数え方について質問があります。
DBAdapter クラスの日付データを SharedMemory に配置しようとしています:
SharedPreferences user = getSharedPreferences(USER, 0);
SharedPreferences.Editor editor = user.edit();
editor.clear();
editor.putString("full_date", fullDate);
今、私のアクティビティで:
SharedPreferences sharedPreferences = getSharedPreferences(USER, 0);
fullDateM = sharedPreferences.getString("full_date","");
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date today = null;
try {
today = df.parse(fullDateM);
} catch (ParseException e1) {
e1.printStackTrace();
}
Calendar now = Calendar.getInstance();
Calendar now2 = Calendar.getInstance();
now.getTime();
now2.setTime(today);
long milis1 = now2.getTimeInMillis();
long milis2 = now.getTimeInMillis();
long diff = milis2 - milis1;
long diffDays = diff / (24 * 60 * 60 * 1000);
しかし、 の値を取得する際にエラーが発生しましたdiffDays
。fullDateM
そして、null ではないことを確認しました。value = "2012-04-27" があります。そして別の質問:diffDays
そのコードで週の差を設定する方法は?