Example usage for java.lang Double Double

List of usage examples for java.lang Double Double

Introduction

In this page you can find the example usage for java.lang Double Double.

Prototype

@Deprecated(since = "9")
public Double(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Double object that represents the floating-point value of type double represented by the string.

Usage

From source file:Main.java

public static String doubleParseToString(double d1) {
    Double d = new Double(d1);
    BigDecimal bd = new BigDecimal(d.toString());
    return bd.toPlainString();
}

From source file:Main.java

public static String roundOffToTwoDecimal(String valueStr) {
    double valueDouble = new Double(valueStr).doubleValue();
    double roundOff = (double) Math.round(valueDouble * 100) / 100;
    return new Double(roundOff).toString();
}

From source file:Main.java

public static Dimension currentWindowSize(double widthRatio, double heightRatio) {
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension rtnDim = new Dimension();
    rtnDim.width = new Double(dim.getWidth() * widthRatio).intValue();
    rtnDim.height = new Double(dim.getHeight() * heightRatio).intValue();
    return rtnDim;
}

From source file:Main.java

public static void staticMethod() {
    // Creates an Integer object from an int
    Integer intObj1 = new Integer(100);

    // Creates an Integer object from a String
    Integer intObj2 = new Integer("1969");

    // Creates a Double object from a double
    Double doubleObj1 = new Double(10.45);

    // Creates a Double object from a String
    Double doubleObj2 = new Double("234.60");

    // Creates a Character object from a char
    Character charObj1 = new Character('A');

    // Creates a Boolean object from a boolean
    Boolean booleanObj1 = new Boolean(true);

    // Creates Boolean objects from Strings
    Boolean booleanTrue = new Boolean("true");
    Boolean booleanFalse = new Boolean("false");
}

From source file:com._17od.upm.gui.MainWindow.java

public static void main(String[] args) {
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {

            try {
                // Use the System look and feel
                Preferences.load();
                Translator.initialise();
                Double jvmVersion = new Double(System.getProperty("java.specification.version"));
                if (jvmVersion.doubleValue() < 1.4) {
                    JOptionPane.showMessageDialog(null, Translator.translate("requireJava14"),
                            Translator.translate("problem"), JOptionPane.ERROR_MESSAGE);
                    System.exit(1);
                } else {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    AppWindow = new MainWindow(applicationName);
                }//from   w  ww .  j  a  v a  2  s. com

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:Main.java

public static Double getDouble(JTextField txt, Double defaultVal) {
    String str = txt.getText();/*  w  w  w.j a va 2 s .c om*/
    if (str.trim().length() <= 0)
        return defaultVal;

    double val = 0;
    try {
        val = Double.parseDouble(str);
    } catch (NumberFormatException ex) {
    }
    return new Double(val);
}

From source file:Main.java

public static double getDoubleProperty(Element properties, String name) {
    return new Double(
            getPropertyNode(properties, name).getAttributes().getNamedItem(DOUBLE_ATTR).getNodeValue());
}

From source file:GetNumber.java

public static Number process(String s) {
    if (s.matches(".*[.dDeEfF]")) {
        try {//from   ww w  .jav a 2 s . c  o m
            double dValue = Double.parseDouble(s);
            System.out.println("It's a double: " + dValue);
            return new Double(dValue);
        } catch (NumberFormatException e) {
            System.out.println("Invalid a double: " + s);
            return NAN;
        }
    } else // did not contain . d e or f, so try as int.
        try {
            int iValue = Integer.parseInt(s);
            System.out.println("It's an int: " + iValue);
            return new Integer(iValue);
        } catch (NumberFormatException e2) {
            System.out.println("Not a number:" + s);
            return NAN;
        }
}

From source file:Main.java

public static List<Double> asList(double[] a) {
    List<Double> result = new ArrayList<Double>(a.length);
    for (double v : a) {
        result.add(new Double(v));
    }/*from   w w  w.ja  v  a 2 s  .c  o m*/
    return result;
}

From source file:Main.java

/**
 * convert latitude from DMS (Degrees, Minutes, Seconds) to DD (Decimal Degrees)
 *
 * @param int latDeg - latitude degree value
 * @param int latMin - latitude minute value
 * @param double latSec - latitude second value
 * @param String latDir - latitude direction (north or south)
 * @return double - double value for given latitude
 *///from  ww  w  . j a  v  a2  s  . c  o  m
public static double convertLatDMStoDD(int latDeg, int latMin, double latSec, String latDir) {
    double latitude = latDeg + (latMin / new Double(60)) + (latSec / new Double(3600));
    if (latDir.equalsIgnoreCase("s"))
        latitude = -latitude;
    return latitude;
}