Quantcast
Channel: How can I pad an integer with zeros on the left? - Stack Overflow
Viewing all articles
Browse latest Browse all 23

Answer by Brijesh Patel for How can I pad an integer with zeros on the left?

$
0
0

Try this one:

import java.text.DecimalFormat; 

DecimalFormat df = new DecimalFormat("0000");
String c = df.format(9);   // 0009
String a = df.format(99);  // 0099
String b = df.format(999); // 0999

Viewing all articles
Browse latest Browse all 23

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>