Last active
January 13, 2022 07:13
-
-
Save Morteza-QN/adbeb3bf5d675a0a2d20157e2bbeac7f to your computer and use it in GitHub Desktop.
Function splits digits numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun splitDigits(number: Long): String? { | |
return try { | |
val decimalFormat = DecimalFormat() | |
val decimalFormatSymbol = DecimalFormatSymbols() | |
decimalFormatSymbol.groupingSeparator = ',' | |
decimalFormat.decimalFormatSymbols = decimalFormatSymbol | |
decimalFormat.format(number) | |
} catch (ex: Exception) { | |
number.toString() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment