Code example for DatePicker

Methods: getDayOfMonthgetMonthgetYearinit

0
		if (isDateAfter(view)) {
			textViewVisible(); 
			Calendar mCalendar = Calendar.getInstance();
			mCalendar.setFirstDayOfWeek(Calendar.MONDAY);
			if (color) {
				view.init(mCalendar.get(Calendar.YEAR),mCalendar.get(Calendar.MONTH),mCalendar.get(Calendar.DAY_OF_MONTH), this);
				color = false;
			} else { 
				view.init(year, month, day, null);
			} 
 
		} else { 
			textViewInvisible(); 
	        updateTitle(year, month, day);
		} 
    } 
 
    private void updateTitle(int year, int month, int day) {
        mCalendar.set(Calendar.YEAR, year);
        mCalendar.set(Calendar.MONTH, month);
        mCalendar.set(Calendar.DAY_OF_MONTH, day);
        setTitle(new DisplayDate(mCalendar).getDisplayDate());
    } 
     
    @Override 
    public Bundle onSaveInstanceState() {
        Bundle state = super.onSaveInstanceState();
        state.putInt(YEAR, mDatePicker.getYear());
        state.putInt(MONTH, mDatePicker.getMonth());
        state.putInt(DAY, mDatePicker.getDayOfMonth());
        return state;
    } 
     
    @Override 
    public void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        int year = savedInstanceState.getInt(YEAR);
        int month = savedInstanceState.getInt(MONTH);
        int day = savedInstanceState.getInt(DAY);
        mDatePicker.init(year, month, day, this);
        updateTitle(year, month, day);
    } 
     
    private void textViewInvisible() { 
		((TextView) findViewById(R.id.new_date_label)).setVisibility(View.INVISIBLE);
	} 
 
	private void textViewVisible() { 
		((TextView) findViewById(R.id.new_date_label)).setVisibility(View.VISIBLE);
	} 
 
	private boolean isDateAfter(DatePicker tempView) {
		Calendar mCalendar = Calendar.getInstance();
		mCalendar.setFirstDayOfWeek(Calendar.MONDAY);
		Calendar tempCalendar = Calendar.getInstance();
		tempCalendar.set(tempView.getYear(), tempView.getMonth(),tempView.getDayOfMonth(), 0, 0, 0);
		tempCalendar.setFirstDayOfWeek(Calendar.MONDAY);
		if (tempCalendar.after(mCalendar))
			return true; 
		else 
			return false;