Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to display decimal point

 
debraj mallick
Ranch Hand
Posts: 188
Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

i need to display the decimal / fractions, but not getting it, when i have

output is :


all i need to display like


i can not use this code to display because it returns string


any help would be appreciated
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15207
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
debraj mallick wrote:i can not use this code to display because it returns string

What do you mean? If you want to display a number, it must be converted to a string somehow. There's no way around that. The question is how you get the string formatted the way you want.

If you want it with 4 decimal places, then specify that in your DecimalFormat:

An alternative is:


Is there a reason why you are using Double (the wrapper class) instead of double (the primitive type)? If not, then prefer double instead of Double.
 
debraj mallick
Ranch Hand
Posts: 188
Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou Jesper de Jong
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic