Releases: robercoding/decimal-formatter
Releases · robercoding/decimal-formatter
v0.2.0-alpha02
🐛 Version 0.2.0-alpha02
🔧 Bug Fixes & Improvements
This release fixes critical issues when dynamically switching between FRACTIONAL and FIXED_DECIMALS input modes, and enhances the demo app with input mode selectors and debug information.
What's Fixed
Input Mode Switching
Previously, when switching between input modes, the rawDigits field would carry over incorrectly, causing unexpected formatting behavior:
Before (Broken):
1. Type "48730" in FRACTIONAL mode → displays "48,730 kg" (48.730)
2. Switch to FIXED_DECIMALS mode
3. Type "1" → displays "487.301,000 kg" ❌ (incorrect!)
Now (Fixed):
1. Type "48730" in FRACTIONAL mode → displays "48,730 kg" (48.730)
2. Switch to FIXED_DECIMALS mode → displays "48,730 kg" (preserved!)
3. Type "1" → displays "48,731 kg" ✅ (correct!)
v0.2.0-alpha01
What's New
Added DecimalInputMode to control how input digits are interpreted:
- FRACTIONAL (Default) - Traditional behavior where digits fill decimal places from the right:
"1"→"0.01" - FIXED_DECIMALS (New) - Treats input as whole numbers with zero-padding:
"1"→"1.00"
The FIXED_DECIMALS mode also accepts formatted input with decimal separators (. or ,).
Example
val formatter = DecimalFormatter(
DecimalFormatterConfiguration.us(
decimalPlaces = 2,
inputMode = DecimalInputMode.FIXED_DECIMALS
)
)
formatter.format("1") // "1.00"
formatter.format("123") // "123.00"
formatter.format("1.5") // "1.50"Changes
Added
DecimalInputModeenum with FRACTIONAL and FIXED_DECIMALS modesinputModeparameter to all DecimalFormatterConfiguration factory methods- Support for parsing decimal separators in FIXED_DECIMALS mode
- 60+ additional test cases
Changed
- Input sanitization preserves decimal separators in FIXED_DECIMALS mode
This release is fully backward compatible. The default mode remains FRACTIONAL.
Installation
dependencies {
implementation("dev.robercoding:decimal-formatter-core:0.2.0-alpha01")
}v0.1.0
Significant API changes in v0.1.0:
- Core layer
- Added percentage DecimalConfiguration
- Added suffix and prefix to DecimalFormatter
- Added "parseableValue" to FormattedDecimal model to later transform it
- Added BigDecimal library to accept formatting from precision values and transform it.
- Ui layer:
- Removed UIDecimalFormatter
- Removed DecimalValue
- Components now accept FormattedDecimal instead of the old and now non-existent DecimalValue model.
0.0.1
Restructure packages and update README.md.
v0.0.1-alpha01
Initial pre-release