Results 1 to 3 of 3

Hi All, Can anyone provide a code sample or two on how to format numbers ... Software & Theme Development forum

  1. #1
    bbCincinnati's Avatar
    bbCincinnati no está en línea Stack level 1
    Join Date
    Mar 2007
    Posts
    13

    JDE / Java - Format Number example?

    Advertisement



    Hi All,

    Can anyone provide a code sample or two on how to format numbers in Blackberry-specific-Java?

    If I have a float, 2.89432.

    I'd like to format it so that it prints out as "2.9".


    Is MessageFormat.format() the right method?

    Can someone provide a really simple code example?

    Thanks,

    Mike

    P.S. If this is the wrong forum, please direct me to the right one. Thank you

  2. #2
    Stimpy5050's Avatar
    Stimpy5050 no está en línea Stack level 1
    Join Date
    Apr 2007
    Posts
    5

    Re: JDE / Java - Format Number example?

    Use DecimalFormat instead...

    Code:
    DecimalFormat df = new DecimalFormat("#.#");
    String str = df.format(2.89432);
    If you want the ',' separator for the thousands, use "#,###.#" instead.

    Quote Originally Posted by bbCincinnati
    Hi All,

    Can anyone provide a code sample or two on how to format numbers in Blackberry-specific-Java?

    If I have a float, 2.89432.

    I'd like to format it so that it prints out as "2.9".


    Is MessageFormat.format() the right method?

    Can someone provide a really simple code example?

    Thanks,

    Mike

    P.S. If this is the wrong forum, please direct me to the right one. Thank you

  3. #3
    bbCincinnati's Avatar
    bbCincinnati no está en línea Stack level 1
    Join Date
    Mar 2007
    Posts
    13

    Re: JDE / Java - Format Number example?

    Hi Stimpy,

    Thank you for your reply! But I don't think the DecimalFormat class is available for Blackberry-specific Java Am I wrong? I hope I'm just missing something here.

    Thanks,

    Mike

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •