Skip to content

Instantly share code, notes, and snippets.

@Morteza-QN
Last active January 13, 2022 07:13
Show Gist options
  • Save Morteza-QN/adbeb3bf5d675a0a2d20157e2bbeac7f to your computer and use it in GitHub Desktop.
Save Morteza-QN/adbeb3bf5d675a0a2d20157e2bbeac7f to your computer and use it in GitHub Desktop.
Function splits digits numbers
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