public static DescriptionStrategy daysOfWeekInstance ( final ResourceBundle bundle , final FieldExpression expression , final FieldDefinition definition ) { final Function < Integer , String > nominal = integer -> { final int diff = definition instanceof DayOfWeekFieldDefinition ? DayOfWeek . MONDAY . getValue ( ) - ( ( DayOfWeekFieldDefinition ) definition ) . getMondayDoWValue ( ) . getMondayDoWValue ( ) : 0 ; return DayOfWeek . of ( integer + diff < 1 ? 7 : integer + diff ) . getDisplayName ( TextStyle . FULL , bundle . getLocale ( ) ) ; } ; final NominalDescriptionStrategy dow = new NominalDescriptionStrategy ( bundle , nominal , expression ) ; dow . addDescription ( fieldExpression -> { if ( fieldExpression instanceof On ) { final On on = ( On ) fieldExpression ; switch ( on . getSpecialChar ( ) . getValue ( ) ) { case HASH : return String . format ( "%s %s %s " , nominal . apply ( on . getTime ( ) . getValue ( ) ) , on . getNth ( ) , bundle . getString ( "of_every_month" ) ) ; case L : return String . format ( "%s %s %s " , bundle . getString ( "last" ) , nominal . apply ( on . getTime ( ) . getValue ( ) ) , bundle . getString ( "of_every_month" ) ) ; default : return "" ; } } return "" ; } ) ; return dow ; }
Creates description strategy for days of week .