Code example for Calendar

Methods: equals, get

0
     * @return The selected year. 
     */ 
    public int getYear() { 
        return mCurrentDate.get(Calendar.YEAR);
    } 
 
    /** 
     * @return The selected month or week. 
     */ 
    public abstract int getPositionInYear(); 
 
    protected abstract int getMaxYear(); 
 
    protected abstract int getMinYear(); 
 
    protected abstract int getMaxPositionInYear(); 
 
    protected abstract int getMinPositionInYear(); 
 
    protected Calendar getMaxDate() {
        return mMaxDate;
    } 
 
    protected Calendar getMinDate() {
        return mMinDate;
    } 
 
    protected Calendar getCurrentDate() {
        return mCurrentDate;
    } 
 
    protected NumberPicker getPositionInYearSpinner() {
        return mPositionInYearSpinner;
    } 
 
    protected NumberPicker getYearSpinner() {
        return mYearSpinner;
    } 
 
    /** 
     * This method should be subclassed to update the spinners based on mCurrentDate. 
     */ 
    protected void updateSpinners() { 
        mPositionInYearSpinner.setDisplayedValues(null);
 
        // set the spinner ranges respecting the min and max dates 
        mPositionInYearSpinner.setMinValue(getMinPositionInYear());
        mPositionInYearSpinner.setMaxValue(getMaxPositionInYear());
        mPositionInYearSpinner.setWrapSelectorWheel(
                !mCurrentDate.equals(mMinDate) && !mCurrentDate.equals(mMaxDate));
 
        // year spinner range does not change based on the current date 
        mYearSpinner.setMinValue(getMinYear());
        mYearSpinner.setMaxValue(getMaxYear());
        mYearSpinner.setWrapSelectorWheel(false);
 
        // set the spinner values