我有两个 EditText。一个带有开始日期,另一个带有结束日期。我需要进行验证并检查结束日期是否大于开始日期。我不知道我该怎么做。
在我的代码中,我在两个日期之间产生差异,现在我还需要检查结束日期是否大于开始日期
这是我的代码:
//EditText with string of start date
dataInicio = (EditText)findViewById(R.id.ses_dpDataIni);
//EditText with string of end date
dataFim = (EditText)findViewById(R.id.ses_dpDataFim);
//Convert String to calendar to check the difference between two dates..
try{
dateInic = dataInicio.getText().toString();
dateFim = dataFim.getText().toString();
calInic=Calendar.getInstance();
calFim = Calendar.getInstance();
calInic.setTime(form.parse(dateInic));
calFim.setTime(form.parse(dateFim));
}
catch (ParseException e) {
e.printStackTrace();
}
Log.w(SessaoQuotaEdit.class.getName(),"DIFERENCA DE DIAS" +daysBetween(calInic,calFim));
tvDiasQuotas = (TextView)findViewById(R.id.ses_tvNumDiasQuota);
tvDiasQuotas.setText("NUMBER OF DAYS: " +daysBetween(calInic,calFim));
//CHECK IS END-DATE IS GREATER THAN START-DATE
.............
.............
你能帮助我吗?谢谢 :)