get Long from String - Java java.lang

Java examples for java.lang:long Parse

Description

get Long from String

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        String content = "java2s.com";
        System.out.println(getLong(content));
    }//from  w  w w. ja  va 2 s .co m

    public static long getLong(String content) {
        long lngContent;
        try {
            lngContent = Long.parseLong(content);
        } catch (Exception e) {
            lngContent = 0L;
        }
        return lngContent;
    }
}

Related Tutorials