private static Locale strip ( Locale locale ) { String language = locale . getLanguage ( ) ; String country = locale . getCountry ( ) ; String variant = locale . getVariant ( ) ; if ( ! variant . isEmpty ( ) ) { variant = "" ; } else if ( ! country . isEmpty ( ) ) { country = "" ; } else if ( ! language . isEmpty ( ) ) { language = "" ; } else { return null ; } return new Locale ( language , country , variant ) ; }
Returns a locale with the most - specific field removed or null if this locale had an empty language country and variant .