Doubt on Formatting a Number

I have a doubt pls anybody clarify it......

I have a String which gets "3600000".....I am converting it to number as 3600000.

But it should be displayed as 36000.00

ie., thirty six thousands.I tried with number formatter but not getting it. Is it possible with number formatter...Is so pls tell me how..

Raju

About ur query-----

You can simply achieve this by applying String
function like intValue()
     stmt would be like this:::-
  int intEquivalent = String.intValue("string value
 to be converted");
         [See java API] for referrence.

Hope your problem would have been solved by this.

Alpana

Thank you for your reply.

I think you didn't get my question.

I am able to convert string to number. but before the last two digits of my number I have to put a dot(.)
If you have an Idea please do the needdful.

Raja

1. convert it to a float/double  instead of a  double;

2. convert to a string;

3. find the position of the ., and use substring to  limit the string to that position +2;

Jonathan Roberts

Will this work?

String s = "36000";
StringBuffer s1 = new StringBuffer(s);
System.out.println(s1.insert(s1.length(2,
'.').toString());

Vinay

I guess I made a typo in my earlier reply, I am sorry.

String s = "3600000",s2;

StringBuffer s1 = new StringBuffer(s);
s2= s1.insert(s1.length()-2, '.').toString();

Anyways, if you meant you want to display 36000.00 as a number, then I got no idea how to do it. Because after you do float a = Float.parseFloat(s2); it will be displayed as 36000.0 but not as 36000.00.

Vinay

Do you have a Java Problem?
Ask It in The Java Forum

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Return to : Java Programming Hints and Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.