Here you can find the source of toLong(Object x)
static Long toLong(Object x)
//package com.java2s; /**//from w w w . j av a 2 s.c o m * Copyright (c) 2012, Thilo Planz. All rights reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the Apache License, Version 2.0 * as published by the Apache Software Foundation (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. * * You should have received a copy of the License along with this program. * If not, see <http://www.apache.org/licenses/LICENSE-2.0>. */ public class Main { static Long toLong(Object x) { if (x == null) return null; if (x instanceof Long) return (Long) x; if (x instanceof Integer) return Long.valueOf(((Integer) x).intValue()); if (x instanceof String) return Long.valueOf((String) x); throw new IllegalArgumentException("cannot convert `" + x + "` into a Long"); } }