RegExp.compile("[0-9]+"); // was [0-9]* but this always returned a match - java: "\\p{Nd}*"
private static CharSequence formatNumber(String component, int value,
String format, boolean defaultFormat, Numberer numberer, XPathContext context)
throws XPathException {
MatchResult matcher = formatPattern.exec(format);
if (matcher == null) {
XPathException error = new XPathException("Unrecognized format picture [" + component + format + ']');
error.setErrorCode("XTDE1340");
error.setXPathContext(context);
throw error;
}
//String primary = matcher.group(1);
//String modifier = matcher.group(2);
String primary = matcher.getGroup(1);
if (primary == null) {
primary = "";
}
String modifier = null;
if (primary.endsWith("t")) {
primary = primary.substring(0, primary.length()-1);
modifier = "t";
} else if (primary.endsWith("o")) {
primary = primary.substring(0, primary.length()-1);
modifier = "o";
}
String letterValue = ("t".equals(modifier) ? "traditional" : null);
String ordinal = ("o".equals(modifier) ? numberer.getOrdinalSuffixForDateTime(component) : null);
String widths = matcher.getGroup(2);
if (widths == null) {
widths = "";
}
if (!alphanumericPattern.test(primary)) {
XPathException error = new XPathException("In format picture at '" + primary +