Java Long Number Create toLong(final String value)

Here you can find the source of toLong(final String value)

Description

To long.

License

Apache License

Parameter

Parameter Description
value the value

Return

the long

Declaration

public static long toLong(final String value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//  ww w.j a  v  a  2  s . c  o m
     * To long.
     *
     * @param value the value
     * @return the long
     */
    public static long toLong(final String value) {
        if (value == null) {
            return 0L;
        }

        String szTemp = "";

        for (int i = 0; i < value.length(); i++)
            if (value.charAt(i) != ',') {
                szTemp = szTemp + value.charAt(i);
            }

        try {
            final double dd = Double.parseDouble(szTemp);
            final long l1 = (long) dd;

            return l1;
        } catch (final NumberFormatException e) {
            final long l = 0L;

            return l;
        }
    }
}

Related

  1. toLong(final Object obj)
  2. toLong(final String bitString)
  3. toLong(final String str, final long defaultValue)
  4. toLong(final String value)
  5. toLong(final String value)
  6. toLong(int numBytes, long value)
  7. toLong(int value)
  8. toLong(int x, int z)
  9. toLong(int[] a)