public static Locale converterTagLocaleFromString ( String name ) { try { Locale locale ; StringTokenizer st = new StringTokenizer ( name , "_" ) ; String language = st . nextToken ( ) ; if ( st . hasMoreTokens ( ) ) { String country = st . nextToken ( ) ; if ( st . hasMoreTokens ( ) ) { String variant = st . nextToken ( ) ; locale = new Locale ( language , country , variant ) ; } else { locale = new Locale ( language , country ) ; } } else { locale = new Locale ( language ) ; } return locale ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Locale parsing exception - " + "invalid string representation '" + name + "'" ) ; } }
Convert locale string used by converter tags to locale .