Here you can find the source of castInt(Object o)
public static Integer castInt(Object o)
//package com.java2s; //License from project: Open Source License public class Main { public static Integer castInt(Object o) { if (o == null) { return 0; } else if (o instanceof Byte) { return (int) (Byte) o; } else if (o instanceof Integer) { return (Integer) o; } else if (o instanceof Double) { return (int) (double) (Double) o; } else if (o instanceof Float) { return (int) (float) (Float) o; } else if (o instanceof Long) { return (int) (long) (Long) o; } else if (o instanceof String) { try { return Integer.parseInt((String) o); } catch (Exception ex) { return 0; }/*from w w w .j av a2 s. c o m*/ } else { return 0; } } }