Java Integer Create toInt(Object objValue)

Here you can find the source of toInt(Object objValue)

Description

to Int

License

Open Source License

Parameter

Parameter Description
objValue Object

Return

int

Declaration

public static int toInt(Object objValue) 

Method Source Code

//package com.java2s;
/*//  w  w w.j  av  a  2 s  .co m
 * Copyright 2005-2020 GreenTube Team All rights reserved.
 * Support: Huxg
 * License: CND team license
 */

public class Main {
    /**
     *
     *
     * @param objValue Object
     *
     * @return int
     */
    public static int toInt(Object objValue) {
        if (objValue != null) {
            if (objValue instanceof Number) {
                return ((Number) objValue).intValue();
            } else {
                return Integer.parseInt(objValue.toString());
            }
        } else
            return 0;
    }

    /**
     * 
     *
     * @param objValue Object
     *
     * @return String
     */
    public static String toString(Object objValue) {
        if (objValue != null)
            return objValue.toString();
        else
            return null;
    }
}

Related

  1. toInt(Object obj)
  2. toInt(Object obj)
  3. toInt(Object obj)
  4. toInt(Object object)
  5. toInt(Object object, int defaultValue)
  6. toInt(Object property, int defaultValue)
  7. toInt(Object val)
  8. toInt(Object val)
  9. toInt(Object value)