void formatEra ( StringBuilder b , ZonedDateTime d , int width , FieldVariants eras ) { int year = d . getYear ( ) ; int index = year < 0 ? 0 : 1 ; switch ( width ) { case 5 : b . append ( eras . narrow [ index ] ) ; break ; case 4 : b . append ( eras . wide [ index ] ) ; break ; case 3 : case 2 : case 1 : b . append ( eras . abbreviated [ index ] ) ; break ; } }
Format the era based on the year .