Date currentDate = new Date(); //获得当前日期
String startStr = "2013-09-25"; //开始日期:2013-09-25 00:00
String endStr = "2013-09-30"; //结束日期:2013-09-29 23:59
Date start = null;
Date end = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
/* 这个必须加,如果不加则报错:"Unhandled exception type ParseException",这是
强制让代码加上异常处理 */
try {
start = sdf.parse(startStr);
end = sdf.parse(endStr);
} catch (java.text.ParseException e) {
e.printStackTrace();
}
if (currentDate.after(start) && currentDate.before(end)) {//91助手
//coding for something
}
String startStr = "2013-09-25"; //开始日期:2013-09-25 00:00
String endStr = "2013-09-30"; //结束日期:2013-09-29 23:59
Date start = null;
Date end = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
/* 这个必须加,如果不加则报错:"Unhandled exception type ParseException",这是
强制让代码加上异常处理 */
try {
start = sdf.parse(startStr);
end = sdf.parse(endStr);
} catch (java.text.ParseException e) {
e.printStackTrace();
}
if (currentDate.after(start) && currentDate.before(end)) {//91助手
//coding for something
}