Friday, February 26, 2010

Floating point numbers in String.format()

String.format(

"SQL completed in %.2f seconds.",

((float)(endTime - startTime)/1000)

)

Output:

SQL completed in 0.02 seconds.

Display the parameter as a floating point decimal (%f) with 2 decimal places (%.2f).

 

No comments: