Code example for Calendar

Methods: getTime, set, setTime

0
     * @param text The text to save 
     */ 
    public void setDate(Date date) {
        final boolean wasBlocking = shouldDisableDependents();
         
        calendar.setTime(date);
         
        persistString((String) DateFormat.format(DATE_FORMAT, calendar.getTime()));
         
        final boolean isBlocking = shouldDisableDependents(); 
        if (isBlocking != wasBlocking) {
            notifyDependencyChange(isBlocking);
        } 
         
        notifyChanged(); 
    } 
     
    private void setDate(String text) {
    	try { 
			setDate(dateFormat.parse(text));
		} catch (ParseException e) {
			// programming error somewhere 
			throw new RuntimeException(e);
		}		 
	} 
     
    /** 
     * Gets the text from the {@link SharedPreferences}. 
     *  
     * @return The current preference value. 
     */ 
    public Date getDate() {
    	calendar.set(Calendar.YEAR, mDatePicker.getYear());
    	calendar.set(Calendar.MONTH, mDatePicker.getMonth());
    	calendar.set(Calendar.DAY_OF_MONTH, mDatePicker.getDayOfMonth());
        return calendar.getTime();
    } 
 
    @Override 
    protected void onBindDialogView(View view) {
        super.onBindDialogView(view);