1
我想檢查當前日期是否等於(或包含)某個定義的日期間隔。我有這樣的事情:ADK Java檢查日期是否等於定義的日期間隔
Calendar c1 = Calendar.getInstance();
SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy");
Date lowerBound = null;
Date upperBound = null;
try {
lowerBound = sdf1.parse("29-10-2013");
upperBound = sdf1.parse("30-12-2013");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
TextView txtdate1 = (TextView) findViewById(R.id.textView1);
if (c1.getTime().before(upperBound) && c1.getTime().after(lowerBound)) {
txtdate1.setText("Is up to date");
} else {
txtdate1.setText("Is not up to date");
}