Is there any function that pads zeros on the left?
The requirements of what I'm trying to do are:
Input:
1234567899
Output:
00000000001234567899
To pad a numeric value with leading zeros to a specific length. Determine how many digits to the left of the decimal you want the string representation of the number to have. Include any leading zeros in this total number of digits. Define a custom numeric format string that uses the zero placeholder "0" to represent the minimum number of zeros.
Is there any function that pads zeros on the left? We don't know the coming input string length. If it is less than 20 we have to pad zeros on the left side. If the input string length is 10 then we have to pad 10 zeros in the left side.
Determine the length of the unpadded numeric string by calling the integer value's ToString ("D").Length or ToString ("X").Length method. Add the number of leading zeros that you want to include in the formatted string to the length of the unpadded numeric string. Adding the number of leading zeros defines the total length of the padded string.
We don't know the coming input string length. If it is less than 20 we have to pad zeros on the left side. If the input string length is 10 then we have to pad 10 zeros in the left side. Show activity on this post.
format-number function can be used for this:
<xsl:value-of select="format-number(1234567899, '00000000000000000000')" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With