Code example for Calendar

Methods: clearclonegetgetTimeInMillisset

0
 
    private void setCurrentDate(int year, int month) {
        if (mCurrentDate == null) {
            mCurrentDate = Calendar.getInstance();
        } 
        mCurrentDate.clear();
        mCurrentDate.set(year, month, 1);
        if (mCurrentDate.getTimeInMillis() < mMinDate.getTimeInMillis()) {
            mCurrentDate = (Calendar) mMinDate.clone();
        } else if (mCurrentDate.getTimeInMillis() > mMaxDate.getTimeInMillis()) {
            mCurrentDate = (Calendar) mMaxDate.clone();
        } 
        updateSpinners(); 
    } 
 
    private static Calendar monthsToCalendar(long months) {
        int year = (int)Math.min(months / 12 + 1970, Integer.MAX_VALUE);
        int month = (int) (months % 12);
        Calendar cal = Calendar.getInstance();
        cal.clear();
Stop searching for code, let great code find you!  Add Codota to your java IDE