private static DateTimeFormatter createFormatterForStyle ( String style ) { if ( style == null || style . length ( ) != 2 ) { throw new IllegalArgumentException ( "Invalid style specification: " + style ) ; } int dateStyle = selectStyle ( style . charAt ( 0 ) ) ; int timeStyle = selectStyle ( style . charAt ( 1 ) ) ; if ( dateStyle == NONE && timeStyle == NONE ) { throw new IllegalArgumentException ( "Style '--' is invalid" ) ; } return createFormatterForStyleIndex ( dateStyle , timeStyle ) ; }
Select a format from a two character style pattern . The first character is the date style and the second character is the time style . Specify a character of S for short style M for medium L for long and F for full . A date or time may be omitted by specifying a style character - .