List of usage examples for java.lang NumberFormatException printStackTrace
public void printStackTrace()
From source file:Main.java
public static final long objectToLong(Object o) { if (o instanceof Number) return ((Number) o).longValue(); try {//from ww w. j ava 2s . c o m if (o == null) return -1L; else return Long.parseLong(o.toString()); } catch (NumberFormatException e) { e.printStackTrace(); return -1L; } }
From source file:Main.java
public static final short objectToShort(Object o) { if (o instanceof Number) return ((Number) o).shortValue(); try {//from ww w . j a v a 2 s.c om if (o == null) return -1; else return Short.parseShort(o.toString()); } catch (NumberFormatException e) { e.printStackTrace(); return -1; } }
From source file:Main.java
public static boolean decimal(Object o) { double n = 0; try {/*from ww w.j a v a 2 s . com*/ n = Double.parseDouble(o.toString().trim()); } catch (NumberFormatException e) { e.printStackTrace(); } if (n > 0.0) { return true; } else { return false; } }
From source file:Main.java
public static boolean num(Object o) { int n = 0;// ww w . jav a 2s . co m try { n = Integer.parseInt(o.toString().trim()); } catch (NumberFormatException e) { e.printStackTrace(); } if (n > 0) { return true; } else { return false; } }
From source file:Main.java
public static int bracketInt(String str, int floor, int ceiling) throws NumberFormatException { int val = 0; try {//from w ww. jav a 2 s . c o m val = Integer.parseInt(str); } catch (NumberFormatException e) { e.printStackTrace(); } return bracketInt(val, floor, ceiling); }
From source file:Main.java
/** * Convert integer wraped in string to int safely. *//*from w ww .j ava 2s. c o m*/ public static int toIntSafely(String text) { int result = -1; text = text.trim(); try { result = Integer.parseInt(text); } catch (NumberFormatException e) { e.printStackTrace(); } return result; }
From source file:Main.java
/** * Convert float value wraped in string to float safely. *///from w w w . j av a2 s . c o m public static float toFloatSafely(String text) { float result = -1.0f; text = text.trim(); try { result = Float.parseFloat(text); } catch (NumberFormatException e) { e.printStackTrace(); } return result; }
From source file:Main.java
public static float bracketFloat(String str, float floor, float ceiling) throws NumberFormatException { float val = 0f; try {/*from w w w .j a va2 s.c o m*/ val = Float.parseFloat(str); } catch (NumberFormatException e) { e.printStackTrace(); } val = bracketFloat(val, floor, ceiling); return val; }
From source file:Main.java
public static String convertToDecimal(String val) { String convertedValue = ""; try {//from ww w. j a v a 2s. c om DecimalFormat df = new DecimalFormat("0.00"); convertedValue = df.format(Double.parseDouble(val)); df.setMaximumFractionDigits(2); } catch (NumberFormatException e) { e.printStackTrace(); } return convertedValue; }
From source file:Main.java
public static int colorForString(String string) { try {/*from w w w . j a v a2 s .c om*/ String colorString = "#" + string; int color = Color.parseColor(colorString); return color; } catch (NumberFormatException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { Log.w(TAG, "Color parsing error from string: " + string); e.printStackTrace(); } return 0; }