Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Thelma Murray   on Oct 04 In Java Category.

  
Question Answered By: Adel Fischer   on Oct 04

You could use the java.text.DecimalFormat class

Documentation attached, sample code found below..

/**
*
* formats a double
*
* @author Kristoffer Hell
*
*/

import java.text.*;

public class DoubleFormatExample {

public static void main (String args[]) {

double dbl = 21345.099876;
System.out.println("as double: " + dbl);
DecimalFormat df = new
DecimalFormat("##########.0");
String fDec = df.format(dbl);
System.out.println(fDec);

}

}

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Number Format Or get search suggestion and latest updates.


Tagged: