Java Object Convert to objToLong(Object obj)

Here you can find the source of objToLong(Object obj)

Description

obj To Long

License

Open Source License

Declaration

public static Long objToLong(Object obj) 

Method Source Code

//package com.java2s;
/**/*from w w  w. j  a  v  a 2s  .  co  m*/
 *  Copyright (c) 2011, StringUtil.java TAIHEIOT and/or its affiliates. All rights reserved.
 *
 *  Licensed under the TAIHEIOT License, Version 1.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  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 Long objToLong(Object obj) {

        return null == obj || "null".equals(obj.toString()) ? 0 : Long.parseLong(obj.toString());

    }
}

Related

  1. objToBoolean(Object o)
  2. objToPrim()
  3. objToTimeLong(Object obj)