---
schema_version: "1"
id: 767d2b3ed90a625cedc42abd79209c1254a4f8d343e2e1872326726d6b7a0a6c
title: Long Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_methods_system_long.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_long.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: b826cc0beef2629724f9271989a6aadbc3793742374ca676785b074a6d198660
description: Contains methods for the Long primitive data type.Returns the String format for this Long using the locale of the context user.Returns the Integer value for this Long.Returns a Long that contains the value of the specified String. As in Java, the string is interpreted as representing a signed decimal Long.
---
# Long Class

Contains methods for the Long primitive data type.

## Namespace

[System](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_System.htm "The System namespace provides classes and methods for core Apex functionality.")

## Usage

For more information on Long, see [Long Data Type](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/langCon_apex_primitives.htm).

## Long Methods

The following are methods for Long.

- **[format()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_long.htm#apex_System_Long_format)**  
    Returns the String format for this Long using the locale of the context user.
- **[intValue()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_long.htm#apex_System_Long_intValue)**  
    Returns the Integer value for this Long.
- **[valueOf(stringToLong)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_long.htm#apex_System_Long_valueOf)**  
    Returns a Long that contains the value of the specified String. As in Java, the string is interpreted as representing a signed decimal Long.

### format()

Returns the String format for this Long using the locale of the context user.

#### Signature

public String format()

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

#### Example

Long myLong = 4271990;
Assert.areEqual('4,271,990', myLong.format());

### intValue()

Returns the Integer value for this Long.

#### Signature

public Integer intValue()

#### Return Value

Type: [Integer](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_integer.htm#apex_methods_system_integer "Contains methods for the Integer primitive data type.")

#### Example

Long myLong = 7191991;
Integer value = myLong.intValue();
Assert.areEqual(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](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

#### Return Value

Type: [Long](#apex_methods_system_long "Contains methods for the Long primitive data type.")

#### Example

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