Java Integer Create toInt(Object value, int nullValue)

Here you can find the source of toInt(Object value, int nullValue)

Description

to Int

License

Open Source License

Declaration

public static int toInt(Object value, int nullValue) 

Method Source Code

//package com.java2s;
/*//w  w w.  j  a v  a2 s  .  co  m
 * This file is part of the Jose Project
 * see http://jose-chess.sourceforge.net/
 * (c) 2002-2006 Peter Sch?fer
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 */

public class Main {
    public static int toInt(Object value, int nullValue) {
        if (value == null)
            return nullValue;
        if (value instanceof Number)
            return ((Number) value).intValue();
        else
            return Integer.parseInt(value.toString());
    }
}

Related

  1. toInt(Object val)
  2. toInt(Object value)
  3. toInt(Object value)
  4. toInt(Object value)
  5. toInt(Object value, int defaultValue)
  6. toInt(Object vo)
  7. toInt(short leftShort, short rightShort)
  8. ToInt(short n1, short n2)
  9. toInt(short s0, short s1)