Skip to content

Commit b17a1c4

Browse files
committed
Thousands separator for numeric settings
1 parent 5a013ed commit b17a1c4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

common/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.lambda.config.settings
22

33
import com.lambda.config.AbstractSetting
4+
import java.text.NumberFormat
5+
import java.util.*
46
import kotlin.reflect.KProperty
57

68
/**
@@ -27,7 +29,9 @@ abstract class NumericSetting<T>(
2729
description,
2830
visibility
2931
) where T : Number, T : Comparable<T> {
30-
override fun toString() = "$value$unit"
32+
private val formatter = NumberFormat.getNumberInstance(Locale.getDefault())
33+
34+
override fun toString() = "${formatter.format(value)}$unit"
3135

3236
override operator fun setValue(thisRef: Any?, property: KProperty<*>, valueIn: T) {
3337
value = valueIn.coerceIn(range)

0 commit comments

Comments
 (0)