double format Scientific - Java java.lang

Java examples for java.lang:double Format

Description

double format Scientific

Demo Code


//package com.java2s;
import java.text.DecimalFormat;

public class Main {
    public static String formatScientific(double datum) {
        DecimalFormat df = new DecimalFormat("0.###E0");
        return df.format(datum);
    }//w  w w .  j  a  v  a 2  s. c o  m

    public static String format(double datum, String pattern) {
        DecimalFormat df = new DecimalFormat(pattern);
        return df.format(datum);
    }
}

Related Tutorials