在我的应用程序中,我想比较两个日期,我的 next_due 日期必须等于和大于当前日期。我对其进行了编码,但它不起作用:(代码中的更正是什么,以便我达到所需的结果请帮助
我的 Java 代码
public void CompareDates(){
Calendar date = Calendar.getInstance();
Calendar next_due_on = Calendar.getInstance();
if(date.before(next_due_on))
System.out.print("Current date(" + new SimpleDateFormat("dd/MM/yyyy").
format(next_due_on.getTime()) + ") is greater than the given date " + new
SimpleDateFormat("dd/MM/yyyy").format(date.getTime()));
else
System.out.print("Both date are equal.");
}
date_txtbx = (EditText) findViewById(R.id.date_txtbx);
date_txtbx.setText(" "
+ String.valueOf(java.text.DateFormat.getDateTimeInstance()
.format(Calendar.getInstance().getTime())));
next_due_on_txtbx = (EditText) findViewById(R.id.next_due_on_txtbx);
next_due_on_txtbx.setText(non_ticket_task.next_due_on);