Here you can find the source of longToInt(Long l)
null
, it returns 0.
public static int longToInt(Long l)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010-2015 BSI Business Systems Integration AG. * 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 ww w .j a v a2 s .c o m*/ * BSI Business Systems Integration AG - initial API and implementation ******************************************************************************/ public class Main { /** * Converts a Long to an int with special attention to overflow issues. * * @return The converted int. If the Long is larger than Integer.MAX_VALUE, it returns Integer.MAX_VALUE. If the Long * is smaller than Integer.MIN_VALUE, it returns Integer.MIN_VALUE. If the parameter is <code>null</code>, it * returns 0. */ public static int longToInt(Long l) { if (l != null) { if (new Long(Integer.MAX_VALUE).compareTo(l) == -1) { return Integer.MAX_VALUE; } else if (new Long(Integer.MIN_VALUE).compareTo(l) == 1) { return Integer.MIN_VALUE; } return l.intValue(); } return 0; } }