I want to check two dates. If two dates are the same then recyclerview will show that day's sell report.
I set a date picker.
DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int year, int month, int day) {
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
calendar.set(Calendar.DAY_OF_MONTH, day);
//mills = calendar.getTimeInMillis();
dateChange();
}
};
tvDate.setOnClickListener(view -> {
DatePickerDialog datePickerDialog = new DatePickerDialog(context, date, calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
datePickerDialog.getDatePicker().setMaxDate(System.currentTimeMillis());
datePickerDialog.show();
});
I want when I pick a date, recyclerview show report from SQLite database on that date. How I will check database date and my date picker date are the same?
I have tried this.
private void dateListArray() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy");
String currDate = simpleDateFormat.format(calendar.getTimeInMillis());
for (ProductModel p : myDatabase.getAllReport()) {
String dates = simpleDateFormat.format(new Date(p.getDate()));
//check datepicker date and allreport date from database
if (currDate == dates){
dateList.add(p)
}else{
}
}
adapter.setFilter(dateList);//filter recyclerview
}
please help.