Here you can find the source of toLong(Object value)
public static Long toLong(Object value)
//package com.java2s; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w . j av a 2 s .c o m * cjdaly - initial API and implementation ****************************************************************************/ public class Main { public static Long toLong(Object value) { if (value instanceof Long) return (Long) value; if (value instanceof Integer) { Integer v = (Integer) value; return v.longValue(); } if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException ex) { // } } return null; } }