Package org.kigalisim.lang.localization
Class NumberParseUtil
java.lang.Object
org.kigalisim.lang.localization.NumberParseUtil
Utility for parsing numbers with flexible thousands and decimal separators.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionparseFlexibleNumber(String numberString) Parse a number string with flexible thousands and decimal separators.
-
Constructor Details
-
NumberParseUtil
public NumberParseUtil()Constructor that initializes the parsing strategies.
-
-
Method Details
-
parseFlexibleNumber
Parse a number string with flexible thousands and decimal separators.This method analyzes the input string to determine whether commas and periods are being used as thousands separators or decimal separators. It supports both European format (123.456,789) and US format (123,456.789).
Logic:- Multiple occurrences of same character = thousands separator
- Single occurrence with ≠3 digits after = decimal separator
- Mixed separators: precedence rules apply (comma before period = comma thousands)
- Single occurrence with exactly 3 digits after = ambiguous (returns error)
- Parameters:
numberString- The number string to parse- Returns:
- FlexibleNumberParseResult containing either parsed number or error message
-