This commit is contained in:
jstaerk
2024-12-04 14:34:34 +01:00
parent 87caa542dd
commit 6c0fcdf876
3 changed files with 18 additions and 2 deletions

View File

@@ -106,7 +106,14 @@ public class NodeMap {
* @return the text content of the matching node, converted to BigDecimal
*/
public Optional<BigDecimal> getAsBigDecimal(String... localNames) {
return getNode(localNames).map(Node::getTextContent).map(s->new BigDecimal(s.trim()));
return getNode(localNames).map(Node::getTextContent).map(s->{
try {
return new BigDecimal(s.trim());
} catch (NumberFormatException e) {
return null;
}
});
}
/**