Java Long Number Create toLong(String value)

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

Description

to Long

License

Open Source License

Declaration

public static long toLong(String value) 

Method Source Code

//package com.java2s;
/**/*from   w  ww.jav  a2s .  c o  m*/
 *  
 * Copyright (c) 2015 Fannie Mae, All rights reserved.
 * This program and the accompany materials are made available under
 * the terms of the Fannie Mae Open Source Licensing Project available 
 * at https://github.com/FannieMaeOpenSource/ezPie/wiki/License
 * 
 * ezPIE? is a registered trademark of Fannie Mae
 * 
 */

public class Main {
    public static long toLong(String value) {
        return toLong(value, 0L);
    }

    public static long toLong(String value, long defaultValue) {
        if (isNullOrEmpty(value))
            return defaultValue;
        try {
            return Long.parseLong(value.trim());
        } catch (NumberFormatException ex) {
            return defaultValue;
        }
    }

    public static boolean isNullOrEmpty(String value) {
        return (value == null) || value.isEmpty();
    }
}

Related

  1. toLong(String v, long def)
  2. toLong(String val)
  3. toLong(String value)
  4. toLong(String value)
  5. toLong(String value)
  6. toLong(String value)
  7. toLong(String value, long _default)
  8. toLong(String value, long def)
  9. toLong(String value, Long defaultValue)