java - Using String format for doubles -
this question has answer here:
- how can pad integers zeros on left? 11 answers
is possible format example double of value 0.41 00.41 using string format ? in other words, possible left 0 pad doubles ? result should show xx.xx
unfortunately haven't been able find simple although sure there simple solution... have tried %02.2f doesn't work...
thank !
try
public class doubleformat { public static void main(string[] args) { float f = 0.41f; string s = float.tostring(f); system.out.println("0"+s); //or system.out.printf("%05.2f\n", f); } }
Comments
Post a Comment