public static Locale toLocale(Object value) throws ConversionException {
        if (value instanceof Locale) {
            return (Locale)value;
        } else if (value instanceof String) {
            List elements = split((String)value, '_');
            int size = elements.size();

            if (size >= 1 &&
                (((String)elements.get(0)).length() == 2 || ((String)elements.get(0)).length() ==
                 0)) {
                String language = (String)elements.get(0);
                String country = (String)((size >= 2) ? elements.get(1) : "");
                String variant = (String)((size >= 3) ? elements.get(2) : "");

                return new Locale(language, country, variant);
            } else {
                throw new ConversionException("The value " + value +
                                              " can't be converted to a Locale");
            }
        } else {
            throw new ConversionException("The value " + value +
                                          " can't be converted to a Locale");
        }
    }