这是我的代码
if (cs1.moveToFirst()) {
curr_date = cs1.getString(0);
exp_date = cs1.getString(1);
account_activation_status = cs1
.getString(2);
status_flag = cs1.getString(3);
Log.e("dates", ">" + cs1.getString(0)
+ " " + cs1.getString(1));
} else {
Log.e("dates", "no table>" + cs1.getString(0)
+ " " + cs1.getString(1));
}
try {
Calendar c = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
formattedDateTime = df.format(c.getTime());
date1 = df.parse(curr_date);
date2 = df.parse(exp_date);
date3 = df.parse(formattedDateTime);
Log.e("dates", "date1=" + date1
+ " date2=" + date2+" date3="+date3);
boolean dateNew1=date3.getTime() < date2.getTime();
if (date3.getTime() < date2.getTime()
&& (!status_flag.matches("D"))
&& (!account_activation_status
.matches("0"))) {
Log.d("expiry", ">1="+status_flag+" 2="+account_activation_status+" 14="+dateNew1);
Log.e("4", "4");
button_yes.setEnabled(true);}
else{
none}
我面临的是即使我将日期转换为特定格式(即dd-MM-yyyy),在某些情况下我会得到(yyyy-MM-dd)。我的情况变得虚假......需要提前帮助