Results 1 to 12 of 12
Like Tree1Likes
  • 1 Post By pbrockway2

Thread: Number Format Help

  1. #1
    glockner is offline Member
    Join Date
    Jan 2015
    Posts
    31
    Rep Power
    0

    Default Number Format Help

    Do not know how to delete posts.
    Last edited by glockner; 01-27-2015 at 11:10 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,007
    Rep Power
    34

    Default Re: Number Format Help

    I see NumberFormat is used in two places. Is that what is wrong?
    What is the current output from the program?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: Number Format Help

    Unless you are concerned about locale, the easiest way is to just use System.out.printf().


    Java Code:
    System.out.printf("$#.2f#n", amt);
    Note: In its infinite wisdom, the spam detector would not let me include percent signs. So when you use the above, use percent signs in place of #.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  4. #4
    glockner is offline Member
    Join Date
    Jan 2015
    Posts
    31
    Rep Power
    0

    Default Re: Number Format Help

    Quote Originally Posted by Norm View Post
    I see NumberFormat is used in two places. Is that what is wrong?
    What is the current output from the program?
    That was the problem thank you!

  5. #5
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,716
    Rep Power
    18

    Default Re: Number Format Help

    System.out.printf("$%.2f%n", amt);

    Java Code:
    System.out.printf("$%.2f%n", amt);
    Weird, works for me.
    Last edited by pbrockway2; 01-27-2015 at 03:25 AM.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,007
    Rep Power
    34

    Default Re: Number Format Help

    What is the current output from the program?
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    glockner is offline Member
    Join Date
    Jan 2015
    Posts
    31
    Rep Power
    0

    Default Re: Number Format Help

    You mean the error message? I forget what it said, but it is fixed now. Thank you!

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,007
    Rep Power
    34

    Default Re: Number Format Help

    You should post any error messages with your first post. It will save a lot of time for everyone.
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    glockner is offline Member
    Join Date
    Jan 2015
    Posts
    31
    Rep Power
    0

    Default Re: Number Format Help

    I am sorry, I am new to this.

  10. #10
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: Number Format Help

    Strange indeed! In fact, I couldn't even reply with quote to your post because of the special characters. Very inconsistent behavior.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  11. #11
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    27

    Default Re: Number Format Help

    It's just possible that moderators are above the law ;)

    db %%%%%%%%%%%%%%
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  12. #12
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,716
    Rep Power
    18

Similar Threads

  1. Crazy Number Format
    By SamJava_the_Hut in forum New To Java
    Replies: 7
    Last Post: 10-12-2013, 06:18 AM
  2. Number format Exception
    By know_how in forum Web Frameworks
    Replies: 2
    Last Post: 01-29-2013, 05:58 PM
  3. Number format Exception
    By aortell24 in forum New To Java
    Replies: 5
    Last Post: 07-16-2012, 06:22 AM
  4. Number format
    By asai in forum New To Java
    Replies: 12
    Last Post: 06-21-2012, 11:24 AM
  5. Replies: 7
    Last Post: 12-30-2010, 02:42 PM

Posting Permissions

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