Newer Version Available
Long Class
Contains methods for the Long primitive data type.
Namespace
Usage
For more information on Long, see Primitive Data Types.
Long Methods
The following are methods for Long.
format()
Returns the String format for this Long using the locale
of the context user.
Signature
public String format()
Return Value
Type: String
Example
1Long myLong = 4271990;
2system.assertEquals('4,271,990', myLong.format());intValue()
Returns the Integer value for this Long.
Signature
public Integer intValue()
Return Value
Type: Integer
Example
1Long myLong = 7191991;
2Integer value = myLong.intValue();
3system.assertEquals(7191991, myLong.intValue());valueOf(stringToLong)
Returns a Long that contains the value of the specified
String. As in Java, the string is interpreted as representing a signed
decimal Long.
Signature
public static Long valueOf(String stringToLong)
Parameters
- stringToLong
- Type: String
Return Value
Type: Long
Example
1Long L1 = long.valueOf('123456789');