Padding to number at the begging using kotlin code
Padding to number at the begging using Koltin code Sometimes we need to show number with leading zero of integer like Entry Number: 000005 So we need padding for that integer. In Kotlin we do it various way: - The padStart() function in Kotlin is a string extension function that pads the beginning of a string with a specified character or sequence of characters until the desired length is reached. The padStart() function takes two parameters: length: The desired length of the resulting string after padding, it is Int type parameter. padChar: The character used for padding. padStart ( 5 , '0' ) here 5 is length of resulting string and ‘0’ is padded when create result string. Example: val yourString = "hello" val paddedResultString = yourString . padStart ( 10 , '*' ) println ( paddedResultString ) // Output String : "*****hello" For Integer Variable: fun padBegining (intData: Int ): String { return ...