<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/EnergyFormatter",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSEnergyFormatter"
  },
  "title" : "EnergyFormatter"
}
-->

# EnergyFormatter

A formatter that provides localized descriptions of energy values.

```
class EnergyFormatter
```

## Overview> Note:
> As of iOS 10, macOS 10.12, tvOS 10, and watchOS 3, Foundation provides the ``doc://com.apple.foundation/documentation/Foundation/MeasurementFormatter`` class, which can be used to represent quantities of ``doc://com.apple.foundation/documentation/Foundation/UnitEnergy`` to provide equivalent functionality to ``doc://com.apple.foundation/documentation/Foundation/EnergyFormatter``. You are encouraged to transition to these new Foundation Units and Measurements APIs whenever possible.

## Topics

### Formatting Energy Strings

[`isForFoodEnergyUse`](/documentation/Foundation/EnergyFormatter/isForFoodEnergyUse)

A Boolean value that indicates whether the energy value is used to measure food energy.

[`getObjectValue(_:for:errorDescription:)`](/documentation/Foundation/EnergyFormatter/getObjectValue(_:for:errorDescription:))

This method is not supported for the `NSEnergyFormatter` class.

[`numberFormatter`](/documentation/Foundation/EnergyFormatter/numberFormatter)

The number formatter used to format the numbers in energy strings.

[`string(fromJoules:)`](/documentation/Foundation/EnergyFormatter/string(fromJoules:))

Returns an energy string for the provided value.

[`string(fromValue:unit:)`](/documentation/Foundation/EnergyFormatter/string(fromValue:unit:))

Returns a properly formatted energy string for the given value and unit.

[`unitString(fromJoules:usedUnit:)`](/documentation/Foundation/EnergyFormatter/unitString(fromJoules:usedUnit:))

Returns the unit string for the provided value.

[`unitString(fromValue:unit:)`](/documentation/Foundation/EnergyFormatter/unitString(fromValue:unit:))

Returns the unit string based on the provided value and unit.

[`unitStyle`](/documentation/Foundation/EnergyFormatter/unitStyle)

The unit style used by this formatter.

### Constants

[`EnergyFormatter.Unit`](/documentation/Foundation/EnergyFormatter/Unit)

The units supported by the `NSEnergyFormatter` class.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)