I am looking for method/way to accomplish this:
try {
DecimalFormat decimalFormatter = new DecimalFormat();
decimalFormatter.setParseBigDecimal(true);
decimalFormatter.parse(inflowTextField.getText());
}
catch(ParseException e)
{
errorMsg+="Invalid inflow value! Must be BigInteger";
}
Above code is inside validation method for TextField
s inside dialog window where user is editing some values and here I want to parse String
from TextField.getText()
into BigDecimal
and if it is impossible then catch exception and make error string which is used in alert popup.
Thing is parse()
method throws exception only when beginning of the string isn't number so examples like '1aaa1aaa1', '1111asdasdasd' etc. don't throw exception. I need them to do it.
In other words I need parser which will throw exception when string input isn't BigDecimal on the very beginning as whole.