DatePicker setMaxDate - 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 setMaxDate 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
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setMaxDate, setMinDate
		GC.add(GregorianCalendar.YEAR, 1);
		long max = GC.getTimeInMillis();
		DatePickerDialog d = new DatePickerDialog(getActivity(), this, year,
				month, day);
		DatePicker dp = d.getDatePicker();
		dp.setMinDate(min);
		dp.setMaxDate(max);
		return d;
		// Create a new instance of DatePickerDialog and return it 
 
	} 
 
	public void onDateSet(DatePicker view, int year, int month, int day) {
		 
		//String dates = date.getText().toString(); 
 
		GregorianCalendar GC = new GregorianCalendar(view.getYear(),
				view.getMonth(), view.getDayOfMonth());
		 
		String newDate = GC.getDisplayName(GregorianCalendar.DAY_OF_WEEK,
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related DatePicker setMaxDate Questions & Answers:

setMaxDate Method Overview
Sets the maximal date supported by this DatePicker in milliseconds since January 1, 1970 00:00:00 in getDefault() time zone.
See Code Examples for other Android DatePicker Methods: