Long Class

Contains methods for the Long primitive data type.

Namespace

System

Usage

For more information on Long, see Long Data Type.

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

Long myLong = 4271990;
system.assertEquals('4,271,990', myLong.format());

intValue()

Returns the Integer value for this Long.

Signature

public Integer intValue()

Return Value

Type: Integer

Example

Long myLong = 7191991;
Integer value = myLong.intValue();
system.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

Long L1 = long.valueOf('123456789');