now handling single qoutes before numbers when decoding UIDs and currencies
This commit is contained in:
parent
01f22b94a2
commit
8bf68f5d66
|
@ -56,8 +56,11 @@ public class StringDecoder {
|
|||
public static double decodeCurrency(String currency) throws IllegalArgumentException, NullPointerException {
|
||||
Objects.requireNonNull(currency);
|
||||
|
||||
// trim and cut out weird leading single quotes for numbers
|
||||
var preparedUID = currency.trim().replaceAll("^\\s*['‘`](?=\\d)", "");
|
||||
|
||||
try {
|
||||
return LOCAL_NUMBER_FORMAT.parse(currency.trim()).doubleValue();
|
||||
return LOCAL_NUMBER_FORMAT.parse(preparedUID).doubleValue();
|
||||
} catch (ParseException ex) {
|
||||
throw new IllegalArgumentException("Not a valid currency in german locale: " + currency, ex);
|
||||
}
|
||||
|
@ -74,10 +77,13 @@ public class StringDecoder {
|
|||
public static int decodeUniqueIdentificationNumber(String number) throws IllegalArgumentException, NullPointerException {
|
||||
Objects.requireNonNull(number);
|
||||
|
||||
// trim and cut out weird leading single quotes for numbers
|
||||
var preparedUID = number.trim().replaceAll("^\\s*['‘`](?=\\d)", "");
|
||||
|
||||
// check if the string is a valid unsigned number
|
||||
try {
|
||||
LOCAL_NUMBER_FORMAT.setParseIntegerOnly(true);
|
||||
var serialNumber = LOCAL_NUMBER_FORMAT.parse(number.trim());
|
||||
var serialNumber = LOCAL_NUMBER_FORMAT.parse(preparedUID);
|
||||
LOCAL_NUMBER_FORMAT.setParseIntegerOnly(false);
|
||||
|
||||
if (serialNumber.intValue() < 0)
|
||||
|
|
Loading…
Reference in New Issue