java - Using String format for doubles -


this question has answer here:

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

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -