2

I need to pre-pend a number of zeroes to a double value in Java. It is simple with integers, for example:

System.out.printf("%08d\n", 1);

Produces: 00000001

If i try the same with a real value:

System.out.printf("%08f\n", 1.1);

The produced output is 1.100000

Hod to i achieve 0000001.1 ?

Thanks.

VilleLipponen
  • 546
  • 1
  • 7
  • 20
  • Possible duplicate of [Left padding a String with Zeros](http://stackoverflow.com/questions/4469717/left-padding-a-string-with-zeros) – Joe C Apr 23 '17 at 16:43

1 Answers1

2

Try this

System.out.println(String.format("%07.1f",1.1F));
Jaydeep Rajput
  • 3,359
  • 14
  • 35