I'm new to Android programming and I'm currently developing an app. Can someone help me on how to validate the date that is being input by the user if is it in range 7 days? so, i have two string 'startDay' and 'endDay' where user input startDay = 1/2/2017 endDay = 6/2/2017
then it went on the next step. and if user input startDay = 1/2/2017 endDay = 9/2/2017 then it return message 'maximum 7 days'
there is the code that i made
@Override
public void onClick(View v) {
if (v==btnSearch){
String startDaystr = startDay.getText().toString();
String startMonthtstr = startMonth.getText().toString();
String endDaystr = endDay.getText().toString();
String endMonthstr = endMonth.getText().toString();
String endYearstr = endYear.getText().toString();
if(Integer.valueOf(startDaystr) >1 && Integer.valueOf(endDaystr) < 8){
sharedPreferenceCustom = SharedPreferenceCustom.getInstance(getContext());
sharedPreferenceCustom.putSharedPref("startDay", startDaystr);
sharedPreferenceCustom.putSharedPref("startMonth",startMonthtstr);
sharedPreferenceCustom.putSharedPref("endDay",endDaystr);
sharedPreferenceCustom.putSharedPref("endMonth",endMonthstr);
sharedPreferenceCustom.putSharedPref("endYear",endYearstr);
startActivity(new Intent(getActivity(), activity_history.class));
}else{
Toast.makeText(getActivity(), "Maximum 7 days!", Toast.LENGTH_LONG).show();
}
}
}
but when im input startDay = 22/2/2017 endDay = 25/2/2017
the result is 'maximum 7 days' it should be return to the next step
please help me..im searched and tried also but not get such a solution..