Format double number

Hello,I'd like to find an easy way to format my double (and add it in a string), as it is possible in C.For example :float my_float = 3.141592653589printf("%.2f\n", my_float) ; prints 3.14.Is it possible ?Thanks for any tips
[288 byte] By [dams@boulot] at [2007-9-30 10:39:41]
# 1

As of 1.5.0, there is:

java.util.Formatter

An interpreter for printf-style format strings. This class provides support for layout justification and alignment, common formats for numeric, string, and date/time data, and locale-specific output. Common Java types such as byte, BigDecimal, and Calendar are supported. Limited formatting customization for arbitrary user types is provided through the Formattable interface.

BIJ001 at 2007-7-3 19:47:02 > top of Java-index,Administration Tools,Sun Connection...
# 2
Formatting numbers before 1.5 is not as easy as what 1.5 will provide but it's not difficult. See the java.text package and in particular NumberFormat and DecimalFormat. I suspect the new 1.5 "printf" like support will probably just be a layer on top of these classes.
cknelsen at 2007-7-3 19:47:02 > top of Java-index,Administration Tools,Sun Connection...