Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9011797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:50:08+00:00 2026-06-16T02:50:08+00:00

Ok so I have been searching for 2 hours on this and please before

  • 0

Ok so I have been searching for 2 hours on this and please before jumping to mark this as a duplicate have a look at the question.

I have a number of strings which contain number

Numbers will all be like this

String one = 611960;
String two = 64850;
String three = 0;
String four = 636;

I want to be able to have these in the correct format as in

6,119.60
648.50
0.00
6.36

I have tried

DecimalFormat df = new DecimalFormat("#,###,###,##0.00");

and converting the String to a double e.g.

double amount = Double.parseDouble(one);

which seems to give 611960.0

then I do

String gfeeOne = df.format(amount);

which in turn gives 611,960.00

So at this stage I’m a bit lost. This should be straightforward and maybe I’m getting lost. I want to cover all cases up to something like this 1000000000 e.g. 1,000,000,000.00

Help very much appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:50:10+00:00Added an answer on June 16, 2026 at 2:50 am

    The Strings you have are interpreted as integers, as they don’t have any sort of decimal separator in them (which is Locale dependent, be careful about that…). So you basically only have to divide your number by 100, or in other words, move the decimal points to the left by two places.

    You should try:

    double amount = Double.parseDouble(one)/100.0;
    

    Or, even better, you could free yourself from the problems of basic floating point rounding problems, and use BigDecimal:

    BigDecimal amount = new BigDecimal(one).movePointLeft(2);
    String gfeeOne = df.format(amount);
    

    Warning if very large values are considered, be sure to use the BigDecimal, as that preserves the precision, while floating point numbers can lose precision.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been reading stackOverflow answers for this question for hours. Please help me.
I have been searching for hours for a solution to this. I want to
I have been searching for a solution for this issue for multiple hours today
I have been searching for hours but I can't seem to understand why this
I have been searching for several hours now how to do this, but can't
I have been searching for a couple hours for a way to accomplish this
I have been searching on this for hours and can not figure out the
Please please help!! I've been searching this for hours but maybe the solution is
I have been searching for hours on how to do this, and am asking
I have been searching and trying to work this out for a few hours.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.