}
}
private void formatNumber(char specifier, String picture, String width, int num, String language,
StringBuilder sb) throws XPathException {
final NumberFormatter formatter = NumberFormatter.getInstance(language);
if ("N".equals(picture) || "n".equals(picture) || "Nn".equals(picture)) {
String name;
switch (specifier) {
case 'M':
name = formatter.getMonth(num);
break;
case 'F':
name = formatter.getDay(num);
break;
case 'P':
name = formatter.getAmPm(num);
break;
default:
name = "";
break;
}
if ("N".equals(picture))
{name = name.toUpperCase();}
if ("n".equals(picture))
{name = name.toLowerCase();}
sb.append(name);
return;
}
// determine min and max width
int min = NumberFormatter.getMinDigits(picture);
int max = NumberFormatter.getMaxDigits(picture);
if (max == 1)
{max = Integer.MAX_VALUE;}
// explicit width takes precedence
final int widths[] = getWidths(width);
if (widths != null) {
if (widths[0] > 0) {min = widths[0];}
if (widths[1] > 0) {max = widths[1];}
}
try {
sb.append(formatter.formatNumber(num, picture, min, max));
} catch (final XPathException e) {
throw new XPathException(this, ErrorCodes.FOFD1350, e.getMessage());
}
}