Skip to content

v0.2.0-alpha01

Latest

Choose a tag to compare

@robercoding robercoding released this 18 Oct 06:59
· 1 commit to main since this release

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

  • DecimalInputMode enum with FRACTIONAL and FIXED_DECIMALS modes
  • inputMode parameter 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")
}