Wicket 导叶浮动转换器设置编号格式

Wicket 导叶浮动转换器设置编号格式,wicket,Wicket,在Wicket 6中,FloatConverter类有一个setNumberFormat方法 在Wicket 7中,它不再可用 我使用它来修改文本字段的默认限制3位小数。 有不同的方法吗?为此使用AbstractDecimalConverter#newNumberFormat(Locale)。您可以覆盖它并配置细节 public class MyFloatConverter extends FloatConverter { @Override protected NumberFormat n

在Wicket 6中,FloatConverter类有一个setNumberFormat方法

在Wicket 7中,它不再可用

我使用它来修改文本字段的默认限制3位小数。
有不同的方法吗?

为此使用
AbstractDecimalConverter#newNumberFormat(Locale)
。您可以覆盖它并配置细节

public class MyFloatConverter extends FloatConverter {
  @Override protected NumberFormat newNumberFormat(final Locale locale)
    {
        NumberFormat nf = NumberFormat.getInstance(locale);
        nf.setXyz(); // <<- customize the NumberFormat here 
        return nf;
    }
}

或者通过重写其
#getConverter(Class)
方法,在特定组件中

为此使用
AbstractDecimalConverter#newNumberFormat(Locale)
。您可以覆盖它并配置细节

public class MyFloatConverter extends FloatConverter {
  @Override protected NumberFormat newNumberFormat(final Locale locale)
    {
        NumberFormat nf = NumberFormat.getInstance(locale);
        nf.setXyz(); // <<- customize the NumberFormat here 
        return nf;
    }
}

或者通过重写其
#getConverter(Class)
方法,在特定组件中

我将MyFloatConverter这样用于我的文本字段:

@Override
public final IConverter getConverter(Class type) {
    FloatConverter fc = new MyFloatConverter();
    return fc;
}

我将MyFloatConverter这样用于我的文本字段:

@Override
public final IConverter getConverter(Class type) {
    FloatConverter fc = new MyFloatConverter();
    return fc;
}

你能举个简短的例子吗。