private void formatWeekdayNumeric ( StringBuilder b , ZonedDateTime d , int firstDay ) { // Java returns ISO-8601 where Monday = 1 and Sunday = 7. int weekday = d . getDayOfWeek ( ) . getValue ( ) ; // Adjust to the localized "first day of the week" int w = ( 7 - firstDay + weekday ) % 7 + 1 ; b . append ( w ) ; }
Convert from Java s ISO - 8601 week number where Monday = 1 and Sunday = 7 . We need to adjust this according to the locale s first day of the week which in the US is Sunday = 0 .