{
Locale lokale = _locale != null ? _locale : facesContext.getViewRoot().getLocale();
if (_pattern == null && _type == null)
{
throw new ConverterException("Cannot get NumberFormat, either type or pattern needed.");
}
// pattern
if (_pattern != null)
{
return new DecimalFormat(_pattern, new DecimalFormatSymbols(lokale));
}
// type
if (_type.equals("number"))
{
return NumberFormat.getNumberInstance(lokale);
}
else if (_type.equals("currency"))
{
return NumberFormat.getCurrencyInstance(lokale);
}
else if (_type.equals("percent"))
{
return NumberFormat.getPercentInstance(lokale);
}
throw new ConverterException("Cannot get NumberFormat, illegal type " + _type);
}