List of utility methods to do Integer Create
int | toInt(final byte[] pBytes) Converts a byte array to an int. return (pBytes[0] & 0xff) << 24 | (pBytes[1] & 0xff) << 16 | (pBytes[2] & 0xff) << 8 | (pBytes[3] & 0xff);
|
int | toInt(final Double value) to Int return Integer.parseInt("" + ((long) Math.floor(value))); |
int[] | toInt(final double[] a, final int len) to Int final int[] b = new int[len]; for (int i = 0; i < len; i++) b[i] = (int) a[i]; return b; |
int | toInt(final int r, final int g, final int b) to Int return DCM_ALPHA_MASK | (r << 16) | (g << 8) | b;
|
int | toInt(final long a) to Int if (a != (int) a) { return a < 0 ? Integer.MIN_VALUE : Integer.MAX_VALUE; return (int) a; |
int | toInt(final long n) to Int if (n > Integer.MAX_VALUE) throw new ArithmeticException(n + " = n > Integer.MAX_VALUE = " + Integer.MAX_VALUE); if (n < Integer.MIN_VALUE) throw new ArithmeticException(n + " = n > Integer.MIN_VALUE = " + Integer.MIN_VALUE); return (int) n; |
int | toInt(final Object obj) to Int try { if (obj instanceof String) { return Integer.valueOf((String) obj).intValue(); } else if (obj instanceof Number) { return ((Number) obj).intValue(); } else { throw new IllegalArgumentException("Could not convert value to integer: " + obj); } catch (Exception e) { throw new IllegalArgumentException("Could not convert value to number: " + obj, e); |
Integer | toInt(final Object valueRep) to Int return Integer.parseInt(String.valueOf(valueRep));
|
int | toInt(final String s) to Int final int number; switch (s.charAt(s.length() - 1)) { case 'K': case 'k': number = Integer.parseInt(s.substring(0, s.length() - 1).trim()) * 1024; break; case 'M': case 'm': ... |
int | toInt(final String str, final int alt) A safe way to parse an integer elsewhere in the code. try { return Integer.parseInt(str); } catch (NumberFormatException nfe) { System.out.println("--- Stack Trace ---"); nfe.printStackTrace(); return alt; |