Java Integer Create toInteger(Object object)

Here you can find the source of toInteger(Object object)

Description

to Integer

License

Educational Community License

Declaration

public static Integer toInteger(Object object) 

Method Source Code

//package com.java2s;
/**********************************************************************************
 *
 * $Id:$// w  w w  .j ava 2s .  c o  m
 *
 ***********************************************************************************
 *
 * Copyright (c) 2008, 2009 The Regents of the University of California
 *
 * Licensed under the
 * Educational Community License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may
 * obtain a copy of the License at
 * 
 * http://www.osedu.org/licenses/ECL-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 *
 **********************************************************************************/

public class Main {
    public static Integer toInteger(Object object) {
        Integer l = null;

        if (object != null) {
            if (object instanceof Integer)
                l = (Integer) object;
            else if (object instanceof String)
                l = Integer.valueOf((String) object);
        }

        return l;
    }
}

Related

  1. toInteger(Object o)
  2. toInteger(Object ob, Integer defaultInteger)
  3. toInteger(Object obj)
  4. toInteger(Object obj)
  5. toInteger(Object obj)
  6. toInteger(Object object)
  7. toInteger(Object object, int defaultValue)
  8. toInteger(Object object, Integer defaultValue)
  9. toInteger(Object str)