How to format an integer with zero-padding in Kotlin

1 Answer

0 votes
fun main() {
    val number = 319

    // Format with leading zeros (6 digits total)
    val formatted = "%06d".format(number)

    println(formatted)
}
 
 
  
/*
run:
  
000319

*/

 



answered Jun 19, 2025 by avibootz

Related questions

...