class LocaleConverter extends AbstractAttributeConverter {

    /**
     * <p>Constructor for LocaleConverter.</p>
     */
    public LocaleConverter() {
        super(Locale.class);
    }

    /** {@inheritDoc} */
    @Override
    protected Locale internalConvert(final Object attribute) {<FILL_FUNCTION_BODY>}
}

        if (attribute instanceof String str) {
            val s = str.replaceAll("-", "_");
            val parts = s.split("_");
            val length = parts.length;
            if (length == 2) {
                return new Locale(parts[0], parts[1]);
            } else if (length == 1) {
                return new Locale(parts[0]);
            }
        }
        return null;
    
<methods>public java.lang.Boolean accept(java.lang.String) ,public java.lang.Object convert(java.lang.Object) <variables>private final non-sealed Class<? extends java.lang.Object> clazz