---
schema_version: "1"
id: db9b66cce54ede39a77581126c5536422e8334f4a760a012d183154e11a91815
title: Boolean Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_methods_system_boolean.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_boolean.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: fa70e5f6638f05135ecda48f5de99a313b6aafe78630a2440ec87d5ecb61fc9f
description: Contains methods for the Boolean primitive data type.Converts the specified string to a Boolean value and returns true if the specified string value is true. Otherwise, returns false.Converts the specified object to a Boolean value. Use this method to convert a history tracking field value or an object that represents a Boolean value.
---
# Boolean Class

Contains methods for the Boolean 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.")

## Boolean Methods

The following are methods for Boolean. All methods are static.

- **[valueOf(stringToBoolean)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_boolean.htm#apex_System_Boolean_valueOf)**  
    Converts the specified string to a Boolean value and returns true if the specified string value is true. Otherwise, returns false.
- **[valueOf(fieldValue)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_boolean.htm#apex_System_Boolean_valueOf_2)**  
    Converts the specified object to a Boolean value. Use this method to convert a history tracking field value or an object that represents a Boolean value.

### valueOf(stringToBoolean)

Converts the specified string to a Boolean value and returns true if the specified string value is true. Otherwise, returns false.

#### Signature

public static Boolean valueOf(String stringToBoolean)

#### Parameters

- **stringToBoolean**: 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: [Boolean](#apex_methods_system_boolean "Contains methods for the Boolean primitive data type.")

#### Usage

If the specified argument is null, this method throws an exception.

#### Example

Boolean b = Boolean.valueOf('true');
Assert.isTrue(b);

### valueOf(fieldValue)

Converts the specified object to a Boolean value. Use this method to convert a history tracking field value or an object that represents a Boolean value.

#### Signature

public static Boolean valueOf(Object fieldValue)

#### Parameters

- **fieldValue**: Type: Object

#### Return Value

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

#### Usage

Use this method with the OldValue or NewValue fields of history sObjects, such as AccountHistory, when the field type corresponds to a Boolean type, like a checkbox field.

#### Example

List<AccountHistory> ahlist = 
     \[SELECT Field,OldValue,NewValue FROM AccountHistory WITH USER\_MODE\];
for(AccountHistory ah : ahlist) {
   System.debug('Field: ' + ah.Field);
   if (ah.field == 'IsPlatinum\_\_c') {
      Boolean oldValue = Boolean.valueOf(ah.OldValue);
      Boolean newValue = Boolean.valueOf(ah.NewValue);
   }
}