Java Long to Int longToInt(long value)

Here you can find the source of longToInt(long value)

Description

Checked conversion from long to int

License

MIT License

Parameter

Parameter Description
value value to convert

Return

value as int

Declaration

public static int longToInt(long value) 

Method Source Code

//package com.java2s;
/*//from   w  w w.  ja v a 2  s .co  m
 * Wegas
 * http://wegas.albasim.ch
 *
 * Copyright (c) 2013, 2014, 2015 School of Business and Engineering Vaud, Comem
 * Licensed under the MIT License
 */

public class Main {
    /**
     * Checked conversion from long to int
     *
     * @param value value to convert
     * @return value as int
     */
    public static int longToInt(long value) {
        if (value > Integer.MAX_VALUE || value < Integer.MIN_VALUE) {
            throw new IllegalArgumentException(value
                    + " is out of Integer's bound");
        }
        return (int) value;
    }
}

Related

  1. longToInt(final Long l, final String name, final int deflt)
  2. longToInt(long d)
  3. longToInt(Long l)
  4. longToInt(long l)
  5. longToInt(Long l)
  6. longToInt(long[] values)
  7. longToIntArr(long[] longArr)
  8. longToIntArray(long value)
  9. longToIntBounds(long value)