@ SuppressWarnings ( "fallthrough" ) protected int handleGetLimit ( int field , int limitType ) { switch ( field ) { case ERA : if ( limitType == MINIMUM || limitType == GREATEST_MINIMUM ) { return 0 ; } return CURRENT_ERA ; case YEAR : { switch ( limitType ) { case MINIMUM : case GREATEST_MINIMUM : return 1 ; case LEAST_MAXIMUM : return 1 ; case MAXIMUM : return super . handleGetLimit ( field , MAXIMUM ) - ERAS [ CURRENT_ERA * 3 ] ; } //Fall through to the default if not handled above } default : return super . handleGetLimit ( field , limitType ) ; } }
Override GregorianCalendar . We should really handle YEAR_WOY and EXTENDED_YEAR here too to implement the 1 .. 5000000 range but it s not critical .