Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Selected date in TO tab always be greater than FROM selection #48

Open
SirajShan opened this issue Aug 28, 2016 · 5 comments
Open
Assignees
Milestone

Comments

@SirajShan
Copy link

If i select a future date in the From tab and i clicked on To tab. It is still showing current date as selected. The To tab value should be same or latter than The value selected in from tab.

@faisalmohd83
Copy link

Any thought on this? any lead would be appreciated.

@irinalomaka
Copy link

We need to have a function to set a data in each tab.

This was referenced Aug 3, 2019
@heysupratim heysupratim changed the title inconsistencies between From and To tab selection Make Selected date in TO tab always be greater than FROM selection Aug 3, 2019
@heysupratim heysupratim self-assigned this Aug 3, 2019
@heysupratim heysupratim added this to the 2.1 milestone Aug 3, 2019
@hawkraph
Copy link

hawkraph commented Aug 5, 2019

@OverRide
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth, int yearEnd, int monthOfYearEnd, int dayOfMonthEnd) {
if(yearEnd < year){
ShowMessage("Please select current or future year");
}else if(monthOfYearEnd < monthOfYear){
ShowMessage("Please select current or future month");
}else if(dayOfMonthEnd < dayOfMonth){
ShowMessage("Please select current or future day");
}else {
String date = "You picked the following date: From- "+dayOfMonth+"/"+(++monthOfYear)+"/"+year+" To "+dayOfMonthEnd+"/"+(++monthOfYearEnd)+"/"+yearEnd;
ShowMessage(date);
}

}

NB: Please watch the month pre-increments. i.e You should only increment once otherwise the month won't be correct

@yasirtahir
Copy link

I think @hawkraph is right. You can put validation once the User click OK button in the onDateSet method. Within this callback method, you can put any type of validation based on your business.

@nikulvaghani
Copy link

@OverRide
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth, int yearEnd, int monthOfYearEnd, int dayOfMonthEnd) {

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
try {
Date fromDate = sdf.parse(dayOfMonth + "/" + monthOfYear + "/" + year);
Date toDate = sdf.parse(dayOfMonthEnd + "/" + monthOfYearEnd + "/" + yearEnd);
if (fromDate.after(toDate)) {
Toast.makeText(this, "To Date must be after the From Date!", Toast.LENGTH_SHORT).show();
return;
}
} catch (ParseException e) {
throw new RuntimeException(e);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants