Long.getLong(String)

来源:互联网 发布:网络维护要什么证件 编辑:程序博客网 时间:2024/06/06 08:44

区分下

Long.getLong 

Long.parseLong

二者的JavaDoc如下:


getLong的:取系统参数的~

Determines the long value of the system property with the specified name.

The first argument is treated as the name of a system property. System properties are accessible through thejava.lang.System.getProperty(java.lang.String) method. The string value of this property is then interpreted as along value and a Long object representing this value is returned. Details of possible numeric formats can be found with the definition ofgetProperty.

If there is no property with the specified name, if the specified name is empty ornull, or if the property does not have the correct numeric format, thennull is returned. 


parseLong的:真正把字符串解析成为Long对象的,如果格式错误则抛出NumberFormat异常!

Parses the string argument as a signed decimal long. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign'-' (\u002D') to indicate a negative value. The resultinglong value is returned, exactly as if the argument and the radix 10 were given as arguments to the parseLong(java.lang.String, int) method.

Note that neither the character L ('\u004C') nor l ('\u006C') is permitted to appear at the end of the string as a type indicator, as would be permitted in Java programming language source code.


0 0
原创粉丝点击