Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By Tolls

Thread: how can i format a double variable to currrency

  1. #1
    mDennis10 is offline Member
    Join Date
    Jul 2011
    Posts
    76
    Rep Power
    0

    Default how can i format a double variable to currrency

    how can i format a double variable to currency and display the result into a Jlabel

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default Re: how can i format a double variable to currrency

    DecimalFormat class.

  3. #3
    mDennis10 is offline Member
    Join Date
    Jul 2011
    Posts
    76
    Rep Power
    0

    Default Re: how can i format a double variable to currrency

    thanks

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,751
    Rep Power
    19

    Default Re: how can i format a double variable to currrency

    Though generally you ought to (in a "real" app) use BigDecimal for currency so you avoid any floating point problems in calculations.
    Of course this is probably an exercise so you can ignore it...:)
    DarrylBurke likes this.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: how can i format a double variable to currrency

    Quote Originally Posted by Junky View Post
    DecimalFormat class.
    I would recommend NumberFormat#getCurrencyInstance()

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

Similar Threads

  1. My double variable adds itself 0.032/33 and 0.064/65
    By Josep_16 in forum New To Java
    Replies: 3
    Last Post: 08-27-2011, 12:55 AM
  2. double type format
    By eleda in forum New To Java
    Replies: 4
    Last Post: 09-17-2010, 07:23 AM
  3. Double Variable Class
    By hypes057 in forum New To Java
    Replies: 9
    Last Post: 09-06-2009, 02:06 PM
  4. variable double problem
    By DarkoDrljaca in forum New To Java
    Replies: 5
    Last Post: 03-02-2009, 08:00 AM
  5. Replies: 3
    Last Post: 01-19-2008, 08:38 AM

Posting Permissions

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