class CharConverter implements PropertyConverter<Character> {

    @Override
    public Character convert(String value, ConversionContext ctx) {
        ctx.addSupportedFormats(getClass(),"\\'<char>\\'", "<char>", "<charNum>");
        if(value==null){
            return null;
        }
        String trimmed = value.trim();
        if(trimmed.isEmpty()){
            return null;
        }
        if(trimmed.startsWith("'")) {
            try {
                if (trimmed.length() == 1){
                    return '\'';
                }
                trimmed = trimmed.substring(1, trimmed.length() - 1);
                if (trimmed.isEmpty()) {
                    return null;
                }
                return trimmed.charAt(0);
            } catch (Exception e) {
                LOG.finest("Invalid character format encountered: '" + value + "', valid formats are 'a', 101 and a.");
                return null;
            }
        }
        try {
            Integer val = Integer.parseInt(trimmed);
            return (char) val.shortValue();
        } catch (Exception e) {
            LOG.finest("Character format is not numeric: '" + value + "', using first character.");
            return trimmed.charAt(0);
        }
    }

}