Re: How to format a float number?

Discussion in 'Java' started by Jon A. Cruz, Aug 20, 2003.

  1. Jon A. Cruz

    Jon A. Cruz Guest

    Michiel Konstapel wrote:
    >>How to format a float number to 2 digits after the decimal point?

    >
    >
    > See java.text.NumberFormat and DecimalFormat.



    Often it's better to use java.text.MessageFormat.


    String format = LoadMyResource( key );

    // Gets a string like
    // "The scale is {0,number,#.##} on {1,number,integer}"
    // or
    // "Ethay alescay onway {1,number,integer} isway {0,number,#.##}"


    String result = MessageFormat.format( format, new Object[] {scale,
    passInt} );
     
    Jon A. Cruz, Aug 20, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy
    Replies:
    7
    Views:
    6,296
    Roedy Green
    May 10, 2004
  2. bd
    Replies:
    0
    Views:
    651
  3. Carsten Fuchs
    Replies:
    45
    Views:
    1,610
    James Kanze
    Oct 8, 2009
  4. Oscar Lok
    Replies:
    1
    Views:
    182
    David Kastrup
    Nov 19, 2006
  5. Fei Liu
    Replies:
    21
    Views:
    2,414
    John Bokma
    Dec 16, 2006
Loading...

Share This Page