i try to save my String value (50000000) into Double format, while I'm trying to show it again in my Edittext, I can't to show it in normal format, and it show as (5E+07), is there any way to convert from double format into String format? I have try this way :

Double value_doble = 5E+07;
EditText.setText(String.valueOf(value_doble);

but its Still show as 5E+07, so my question how to convert from Double to String?

有帮助吗?

解决方案

You can try this:

    System.out.println(new BigDecimal(value_doble).toString());

其他提示

Is this what you are looking for?

  public static void main(String[] args) {
       Double value_doble = 5E+07;
       NumberFormat formatter = new DecimalFormat("###.#####");   
       String f = formatter.format(value_doble);   
       System.out.println(f);
}

I agree that you need use Formater http://docs.oracle.com/javase/tutorial/i18n/format/decimalFormat.html

but the pattern should be look like this:

import java.text.DecimalFormat;
import java.text.NumberFormat;


public class DoubleFormat {

    public static void main(String[] args) {
        double valueD = 5E+07;
        NumberFormat format = new DecimalFormat("#");
        System.out.println(format.format(valueD));
    }

}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top