Start date and End date DateDialogPickers - android

I have two DatePickerDialogs, one is for start date and one for end date. I need that every time the user open the end date Dialog the min date will be the start date dialog's date. Notice that the start date is not constant and the user can change it anytime.

If i understood correctly. You should do something like this:
Get your start date Calendar instance.
Set your end date minimum date from start date Calendar instance.
datePickerDialog.getDatePicker().setMinDate(startDateCalendar.getTimeInMillis());

Related

How to disable all previous dates from selected date in datepicker in android

I want to disable all previous dates in one date picker while i select a date in another date picker. Please don't put answer to disable all previous dates from current date. I want from selected date, not from current date.
Such as i selected 22Dec on first date picker, Now in second date picker, all previous dates from 22Dec should be disable.

How can i disable specific date

I want to disable the specific dates which user selected in another date picker
I mean user selects date in first date in date picker and another date picker sets minimum date?
That functionality does not available in Android DatePicker. You need to use a custom date picker.
You can use MaterialDateTimePicker library, here you can set an option to disable specific dates by using setDisabledDays() API.
For Example:
datePicker.setDisabledDays(Calendar[] days)
You need to pass array of Calendar days as an parameter which should contains all the disable dates.
you can use setMinDate() function to set the minimum date in date picker.

Setting android datepicker min date to specific date

I want the user to be able to pick start date and end date. The minimum of end date must be equal to start date. For example the user selects August 1 2014 as a start date. When he clicks on the return date field these values are passed to date_picker_activity as intent extras. In the date_picker_activity I check for these extras and currently it just sets the selected date as the displayed date:
if(getIntent().getExtras()!=null)
{
int year = getIntent().getExtras().getInt("SELECTED_YEAR");
int month = getIntent().getExtras().getInt("SELECTED_MONTH");
int day = getIntent().getExtras().getInt("SELECTED_DAY");
date_picker.updateDate(year, month, day);
}
but the user is still able to pick dates prior to selected start date.
I tried to do something like that inside that if statement:
Time time = new Time();
time.set(day, month, year);
date_picker.setMinDate(time.toMillis(true)-1000);
but that didn't work.
How can I set the min date with the passed values?
After discussing on chat, we managed to understand that this code:
date_picker.setMinDate(System.currentTimeMillis() - 1000);
was being called anyway inside the if statement, setting the minimum date to the current Date.
Once Igal moved that code to an else statement, all is working ok.

How to include date and time picker in same dialog box and display the date and time in a single textbox in yyyy-mm-dd hh:ii:ss format in Android

I need to include a date with time in a textbox in 'yyyy-mm-dd hh:ii:ss format' using a date and time picker from a single dialog box (without using different dialog box for date and time picker).
Take a look here how to show dialog to pick date and time togather?
And alternate solutions are :
Date slider
Date time picker
Date Time Picker
And for formatting to show date and time is your own and easy task, I think now you can do it.

How to get current date with time and setting it to a editbox in android?

How to get current date with time in android and how can we set that
date andtime to a editbox.
You can get current date and time using:
Calendar cal=Calendar.getInstance();
Now simply show this in your editbox like:
editBox.setText(String.format("%1$te %1$tB %1$tY %1$r",cal));
This will give you date and time like- 12 January 2009 10:34:50 pm
For displaying other date and time formats,please refer to http://download.oracle.com/javase/1.5.0/docs/api/java/util/Formatter.html

Categories

Resources