I am working on DatePicker in android 1.5. I am trying to set Maximum and minimum date.Minimum date should be the current date and maximum date should be the date which I wi
This way, i solved my problem
DateDP.init(minYear, minMonth, minDay, new OnDateChangedListener()
{
public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth)
{
if (year > maxYear ||monthOfYear > maxMonth && year == maxYear||
dayOfMonth > maxDay && year == maxYear && monthOfYear == maxMonth){
// Toast.makeText(DatePickerActivity.this,"max year", Toast.LENGTH_SHORT).show();
view.updateDate(maxYear, maxMonth, maxDay);
dateOutput = String.format("%04d-%02d-%02d",
maxYear, maxMonth+1, maxDay);
//Toast.makeText(DatePickerActivity.this,"maxYear "+dateOutput, Toast.LENGTH_SHORT).show();
}else if(year < minYear ||monthOfYear < minMonth && year == minYear||
dayOfMonth < minDay && year == minYear && monthOfYear == minMonth){
//Toast.makeText(DatePickerActivity.this,"min year", Toast.LENGTH_SHORT).show();
view.updateDate(minYear, minMonth, minDay );
dateOutput = String.format("%04d-%02d-%02d",
minYear, minMonth+1, minDay);
//Toast.makeText(ManageShowing.this,dateOutput, Toast.LENGTH_SHORT).show();
}else{
//Toast.makeText(ManageShowing.this,"else", Toast.LENGTH_SHORT).show();
dateOutput = String.format("%04d-%02d-%02d",
year, monthOfYear+1, dayOfMonth);
// Toast.makeText(ManageShowing.this,dateOutput, Toast.LENGTH_SHORT).show();
}
mDateDisplay.setText(dateOutput);
}}); // DateDP.init()