Skip to content

Instantly share code, notes, and snippets.

View mattiz's full-sized avatar

Mathias Bjerke mattiz

View GitHub Profile
public class LocaleUtil {
private static Pattern pattern = Pattern.compile("^([a-z][a-z])(_([A-Z][A-Z]))?$");
/**
* Returns null if the string couldn't be parsed
*/
public static Locale parseStringToLocale(String s) {
Matcher matcher = pattern.matcher(s);
if(!matcher.matches()) {