Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the date for a date picker?

Tags:

android

I use DatePickerDialog.OnDateSetListener that's works fine.

I want to add date for 120 days in date picker.

What I mean is if I add 120 days, the date and month will be change automatically. How to do it?

like image 948
shivcena Avatar asked Aug 13 '12 12:08

shivcena


People also ask

How do you set a date picker date?

jQuery UI datepicker setDate() method is used to set the date from the date field. Parameters: This method does not accept any parameters. Return values: This method returns the date. Approach: First, add jQuery mobile scripts needed for your project.

How do I change the default date in datepicker?

Syntax: $(". selector"). datepicker( {defaultDate:"+6"} );

How do I restrict date in date picker?

You can restrict the users from selecting a date within the particular range by specifying MinDate and MaxDate properties. The default value of MinDate property is 1/1/1920 and MaxDate property is 12/31/2120 . Dates that appears outside the minimum and maximum date range will be disabled (blackout).

How do I insert the date picker to default date in Word?

In the Data type box, click Date and Time (dateTime). Click Format. In the Date and Time Format dialog box, in the Display the time like this list, click the option that you want, and then click OK. In the Date Picker Properties dialog box, under Default Value, click Insert Formula .


1 Answers

Something like this should do the trick:

Calendar cal = Calendar.getInstance();
cal.set(datepick.getYear(), datepick.getMonth() + 1, datepick.getDayOfMonth());
cal.add(Calendar.DATE, 120);
datepick.updateDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) - 1, cal.get(Calendar.DATE));
like image 198
Aleks G Avatar answered Sep 21 '22 06:09

Aleks G