DatePicker updateDate - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for DatePicker updateDate method.

This code example shows how to use the following methods:getDayOfMonth, getMonth, getYear, setMaxDate, setMinDate
     if (max <= min) {
         return; 
     } 
     Calendar minCal = trimToDate(min);
     Calendar maxCal = trimToDate(max);
     int currentYear = picker.getYear();
     int currentMonth = picker.getMonth();
     int currentDayOfMonth =  picker.getDayOfMonth();
     picker.updateDate(maxCal.get(Calendar.YEAR),
             maxCal.get(Calendar.MONTH),
             maxCal.get(Calendar.DAY_OF_MONTH));
     picker.setMinDate(minCal.getTimeInMillis());
     picker.updateDate(minCal.get(Calendar.YEAR),
             minCal.get(Calendar.MONTH),
             minCal.get(Calendar.DAY_OF_MONTH));
     picker.setMaxDate(maxCal.getTimeInMillis());
 
     // Restore the current date, this will keep the min/max settings 
     // previously set into account. 
     picker.updateDate(currentYear, currentMonth, currentDayOfMonth);

8
CodeRank
This code example shows how to use the following methods:getDayOfMonth, getMonth, getYear, setMaxDate, setMinDate
     if (max <= min) {
         return; 
     } 
     Calendar minCal = trimToDate(min);
     Calendar maxCal = trimToDate(max);
     int currentYear = picker.getYear();
     int currentMonth = picker.getMonth();
     int currentDayOfMonth =  picker.getDayOfMonth();
     picker.updateDate(maxCal.get(Calendar.YEAR),
             maxCal.get(Calendar.MONTH),
             maxCal.get(Calendar.DAY_OF_MONTH));
     picker.setMinDate(minCal.getTimeInMillis());
     picker.updateDate(minCal.get(Calendar.YEAR),
             minCal.get(Calendar.MONTH),
             minCal.get(Calendar.DAY_OF_MONTH));
     picker.setMaxDate(maxCal.getTimeInMillis());
 
     // Restore the current date, this will keep the min/max settings 
     // previously set into account. 
     picker.updateDate(currentYear, currentMonth, currentDayOfMonth);

7
CodeRank
This code example shows how to use the following methods:getDayOfMonth, getMonth, updateDate
dp.updateDate(1900, dp.getMonth(), dp.getDayOfMonth());
                    } 
                    else 
                    { 
                        dp.updateDate(Calendar.getInstance().get(Calendar.YEAR), dp.getMonth(), dp.getDayOfMonth());
                    } 
                } 
            } 
        }); 
        displayYearField(!cbRepeatAnnualy.isChecked());
 
        Button btnSave = (Button) findViewById(R.id.btnHolSave);
        btnSave.setOnClickListener(new View.OnClickListener() {
            @Override 
            public void onClick(View v) {
                dateHol = SetDate(dp.getYear(), dp.getMonth() + 1, dp.getDayOfMonth());
                if (cbRepeatAnnualy.isChecked()) {
                    dateHol.setYear(0);
                } 
6
CodeRank
This code example shows how to use the following methods:updateDate
     * @param monthOfYear The date month. 
     * @param dayOfMonth The date day of month. 
     */ 
    public void updateDateTime(int year, int monthOfYear, int dayOfMonth,
            int hourOfDay, int minutOfHour) {
        mDatePicker.updateDate(year, monthOfYear, dayOfMonth);
        mTimePicker.setCurrentHour(hourOfDay);
        mTimePicker.setCurrentMinute(minutOfHour);
    } 
} 
5
CodeRank
This code example shows how to use the following methods:updateDate
     * @param monthOfYear The date month. 
     * @param dayOfMonth The date day of month. 
     */ 
    public void updateDateTime(int year, int monthOfYear, int dayOfMonth,
            int hourOfDay, int minutOfHour) {
        mDatePicker.updateDate(year, monthOfYear, dayOfMonth);
        mTimePicker.setCurrentHour(hourOfDay);
        mTimePicker.setCurrentMinute(minutOfHour);
    } 
 
    @Override 
    public Bundle onSaveInstanceState() {
        Bundle state = super.onSaveInstanceState();
        state.putInt(YEAR, mDatePicker.getYear());
        state.putInt(MONTH, mDatePicker.getMonth());
        state.putInt(DAY, mDatePicker.getDayOfMonth());
        state.putInt(HOUR, mTimePicker.getCurrentHour());
        state.putInt(MINUTE, mTimePicker.getCurrentMinute());
        state.putBoolean(IS_24_HOUR, mTimePicker.is24HourView());
        return state;
5
CodeRank
This code example shows how to use the following methods:setMaxDate, setMinDate, updateDate
        DatePickerDialog dpd=new DatePickerDialog( getActivity(), this, year, month, day );
        DatePicker dp=dpd.getDatePicker();
        long currentTimeInMs=System.currentTimeMillis();
        long pastLimitInMs=1000L;             // One second in the past
        long futureLimitInMs=31536000000L;    // One year into the future
        dp.setMinDate( currentTimeInMs - pastLimitInMs );
        dp.setMaxDate( currentTimeInMs + futureLimitInMs );
        dp.updateDate( year, month, day );
        return dpd;
    } 
 
    @Override 
    public void onDateSet( DatePicker view, int year, int monthOfYear, int dayOfMonth )
    { 
        EditText edtNextDate=( EditText ) getActivity().findViewById( R.id.cedt_next_date );
        Calendar c=Calendar.getInstance();
        c.set( year, monthOfYear, dayOfMonth );
        Date d=new Date( c.getTimeInMillis() );
        edtNextDate.setText( LawyerDiariesHelper.convertDateToString( d ) );
    } 
5
CodeRank
This code example shows how to use the following methods:updateDate
 
	public void setTime(long time) {
		if (picker != null) {
			Calendar cal = Calendar.getInstance();
			cal.setTimeInMillis(time);
			picker.updateDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY),
					cal.get(Calendar.DAY_OF_MONTH));
			setSummaryTime(cal.getTimeInMillis());
		} 
	} 
 
	@Override 
	protected Parcelable onSaveInstanceState() {
		final Parcelable superState = super.onSaveInstanceState();
		if (picker == null) {
			return superState;
		} 
 
		final SavedState myState = new SavedState(superState);
		myState.time = getTime();
5
CodeRank
This code example shows how to use the following methods:updateDate
			activityUtils.getCurrentActivity(false).runOnUiThread(new Runnable()
			{ 
				public void run() 
				{ 
					try{ 
						datePicker.updateDate(year, monthOfYear, dayOfMonth);
					}catch (Exception ignored){}
				} 
			}); 
		} 
	} 
 
 
	/** 
	 * Sets the time in a given {@link TimePicker}. 
	 * 
	 * @param timePicker the {@code TimePicker} object. 
	 * @param hour the hour e.g. 15 
	 * @param minute the minute e.g. 30 
	 * 
4
CodeRank
This code example shows how to use the following methods:updateDate
		setTime(time.getTime());
	} 
 
	public void setTime(long millis) {
		Calendar cal = Calc.cal(millis);
		datePicker.updateDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
		timePicker.setCurrentHour(cal.get(Calendar.HOUR_OF_DAY));
		timePicker.setCurrentMinute(cal.get(Calendar.MINUTE));
		onTimeChanged(millis);
	} 
 
	public void setTimeFirst(boolean timeFirst) {
		this.timeFirst = timeFirst;
	} 
 
	protected void onTimeChanged(long millis) {
	} 
} 
4
CodeRank
This code example shows how to use the following methods:updateDate
    /** {@inheritDoc} */ 
	@Override 
	public void setAnswer(String answer) {
		dateAnswer = new Date(answer);
		if (isViewActive()) { 
			dp.updateDate(dateAnswer.getYear(), dateAnswer.getMonth(), 
					dateAnswer.getDay());
		} 
	} 
	 
	private DateElement(String id, String question, String answer, 
			String concept, String figure, String audio) 
	{ 
        super(id, question, answer, concept, figure, audio);
    } 
     
    /**  
     * Creates the element from an XML procedure definition. 
     *  
     * @param id The unique identifier of this element within its procedure. 
4
CodeRank

Related DatePicker updateDate Questions & Answers:

updateDate Method Overview
Updates the current date.
See Code Examples for other Android DatePicker Methods: