List of usage examples for java.lang Double valueOf
@HotSpotIntrinsicCandidate public static Double valueOf(double d)
From source file:Main.java
/** * Set the last searched location//from ww w . j a v a 2s . c om */ public static void setLastSearchedLocation(Context context, double latitude, double longitude) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = prefs.edit(); String strLatitude = Double.valueOf(latitude).toString(); String strLongitude = Double.valueOf(longitude).toString(); editor.putString(FM_LOCATION_LATITUDE, strLatitude); editor.putString(FM_LOCATION_LONGITUDE, strLongitude); editor.commit(); }
From source file:Main.java
private static Object readThisPrimitiveValueXml(XmlPullParser parser, String tagName) throws XmlPullParserException { try {/*from ww w . ja v a2 s . co m*/ switch (tagName) { case "int": return Integer.parseInt(parser.getAttributeValue(null, "value")); case "long": return Long.valueOf(parser.getAttributeValue(null, "value")); case "float": return Float.valueOf(parser.getAttributeValue(null, "value")); case "double": return Double.valueOf(parser.getAttributeValue(null, "value")); case "boolean": return Boolean.valueOf(parser.getAttributeValue(null, "value")); default: return null; } } catch (NullPointerException e) { throw new XmlPullParserException("Need value attribute in <" + tagName + ">"); } catch (NumberFormatException e) { throw new XmlPullParserException("Not a number in value attribute in <" + tagName + ">"); } }
From source file:Main.java
public static Double getBitmapsize(Bitmap bitmap, int sizeType) { long fileS = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { // fileS = bitmap.getByteCount(); Bitmap.Config config = bitmap.getConfig(); if (config == Bitmap.Config.RGB_565 || config == Bitmap.Config.ARGB_4444) { fileS = bitmap.getWidth() * bitmap.getHeight() * 2; } else if (config == Bitmap.Config.ALPHA_8) { fileS = bitmap.getWidth() * bitmap.getHeight(); } else if (config == Bitmap.Config.ARGB_8888) { fileS = bitmap.getWidth() * bitmap.getHeight() * 4; }//w w w . j av a 2s . c o m } else { fileS = bitmap.getRowBytes() * bitmap.getHeight();// Pre HC-MR1 } DecimalFormat df = new DecimalFormat("#.00"); double fileSizeLong = 0; switch (sizeType) { case SIZETYPE_B: fileSizeLong = Double.valueOf(df.format((double) fileS)); break; case SIZETYPE_KB: fileSizeLong = Double.valueOf(df.format((double) fileS / 1024)); break; case SIZETYPE_MB: fileSizeLong = Double.valueOf(df.format((double) fileS / 1048576)); break; case SIZETYPE_GB: fileSizeLong = Double.valueOf(df.format((double) fileS / 1073741824)); break; default: break; } return fileSizeLong; }
From source file:Student.java
@Override public int compareTo(Student o) { if (o == null) { return -1; }//from w ww .j ava 2s .co m int c = Double.valueOf(grade).compareTo(o.grade); if (c != 0) { return c; } return name.compareTo(o.name); }
From source file:Main.java
public static Object typeConversion(Class<?> cls, String str) { Object obj = null;// w w w . j av a 2s . c o m String nameType = cls.getSimpleName(); if ("Integer".equals(nameType)) { obj = Integer.valueOf(str); } if ("String".equals(nameType)) { obj = str; } if ("Float".equals(nameType)) { obj = Float.valueOf(str); } if ("Double".equals(nameType)) { obj = Double.valueOf(str); } if ("Boolean".equals(nameType)) { obj = Boolean.valueOf(str); } if ("Long".equals(nameType)) { obj = Long.valueOf(str); } if ("Short".equals(nameType)) { obj = Short.valueOf(str); } if ("Character".equals(nameType)) { obj = str.charAt(1); } return obj; }
From source file:PrimitiveUtils.java
public static Object read(String value, Class type) { Object ret = value;//from ww w . j a v a2 s . co m if (Integer.TYPE.equals(type)) { ret = Integer.valueOf(value); } if (Byte.TYPE.equals(type)) { ret = Byte.valueOf(value); } if (Short.TYPE.equals(type)) { ret = Short.valueOf(value); } if (Long.TYPE.equals(type)) { ret = Long.valueOf(value); } if (Float.TYPE.equals(type)) { ret = Float.valueOf(value); } if (Double.TYPE.equals(type)) { ret = Double.valueOf(value); } if (Boolean.TYPE.equals(type)) { ret = Boolean.valueOf(value); } if (Character.TYPE.equals(type)) { ret = value.charAt(0); } // TODO others. return ret; }
From source file:Main.java
/** * Get the latest searched location/*from w w w. j a va 2 s.c om*/ * @return the list of latitude and longitude */ public static double[] getLastSearchedLocation(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String strLatitude = prefs.getString(FM_LOCATION_LATITUDE, "0.0"); String strLongitude = prefs.getString(FM_LOCATION_LONGITUDE, "0.0"); double latitude = Double.valueOf(strLatitude); double longitude = Double.valueOf(strLongitude); return new double[] { latitude, longitude }; }
From source file:Main.java
/** Return the value of an attribute of a node as a real number or <code>null</code> if the attribute is not present. *///from ww w. jav a 2 s . c o m static public Double getDoubleAttribute(Node node, String att_name) { if (node == null) return null; String text = getText(node.getAttributes().getNamedItem(att_name)); if (text == null) return null; return Double.valueOf(text); }
From source file:Main.java
public static double getArg(final NodeList args, final String strName, final double dDefaultValue) { final String strValue = getArg(args, strName, null); if (strValue == null) { return dDefaultValue; }/*from ww w.ja va2 s. com*/ return Double.valueOf(strValue); }
From source file:com.adaptris.core.services.splitter.MessageCopier.java
protected static int toInteger(String s) { if (isEmpty(s)) { return 0; }//from w ww . java 2s.c om return Double.valueOf(s).intValue(); }