我想检查当前日期是否等于(或包含)某个定义的日期间隔。我有这样的事情:
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");
}