Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

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

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

Return Value

Type: Long

Example

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