Java Long Number From toLongs(Long[] values)

Here you can find the source of toLongs(Long[] values)

Description

to Longs

License

Open Source License

Declaration

public static long[] toLongs(Long[] values) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static final long DEFAULT_LONG = 0L;

    public static long[] toLongs(Long[] values) {
        return toLongs(values, DEFAULT_LONG);
    }/* w  ww  .  j av a 2s .c  om*/

    public static long[] toLongs(Long[] values, long defaultValue) {
        long[] results = new long[0];
        if (values != null) {
            results = new long[values.length];
            for (int i = 0; i < results.length; i++) {
                Long element = values[i];
                try {
                    results[i] = (element != null ? element.longValue()
                            : defaultValue);
                } catch (Exception ex) {
                    // ex.printStackTrace();
                }
            }
        }
        return results;
    }

    public static Long[] toLongs(long[] values) {
        return toLongs(values, DEFAULT_LONG);
    }

    public static Long[] toLongs(long[] values, long defaultValue) {
        Long[] results = new Long[0];
        if (values != null) {
            results = new Long[values.length];
            for (int i = 0; i < results.length; i++) {
                long element = values[i];
                try {
                    results[i] = new Long(element);
                } catch (Exception ex) {
                    results[i] = defaultValue;
                    // ex.printStackTrace();
                }
            }
        }
        return results;
    }
}

Related

  1. toLongObject(Object obj)
  2. toLongs(byte[] bytes)
  3. toLongs(byte[] readBuffer, int o, int l)
  4. toLongs(byte[] value, int offset, int num)
  5. toLongs(int[] array)
  6. toLongTime()
  7. toLongTimestamp(Object cell)
  8. toLongUnsigned(int intValue)
  9. toLongValue(byte... bytes)