---
title: Duration.UnitsFormatStyle.ZeroValueUnitsDisplayStrategy
framework: swift
role: symbol
role_heading: Structure
path: swift/duration/unitsformatstyle/zerovalueunitsdisplaystrategy
---

# Duration.UnitsFormatStyle.ZeroValueUnitsDisplayStrategy

A strategy that determines how to format a unit whose value is zero.

## Declaration

```swift
struct ZeroValueUnitsDisplayStrategy
```

## Overview

Overview When using a Duration.UnitsFormatStyle, specifying a ZeroValueUnitsDisplayStrategy enables you to decide whether show a unit whose value is zero. The following example creates a duration of 25 seconds, then formats it with two different styles. The first style uses the hide display strategy, which omits the hours and minutes, since their value is 0. The second uses show(length:) to create two-digit representations of the hour and minute fields. let duration = Duration.seconds(25) let hide = duration.formatted(     .units(allowed: [.hours, .minutes, .seconds],            width: .abbreviated,            zeroValueUnits:.hide)) // 25 sec let showTwo = duration.formatted(     .units(allowed: [.hours, .minutes, .seconds],            width: .abbreviated,            zeroValueUnits:.show(length: 2))) // 00 hr, 00 min, 25 sec

## Topics

### Using common strategies

- [hide](swift/duration/unitsformatstyle/zerovalueunitsdisplaystrategy/hide.md)
- [show(length:)](swift/duration/unitsformatstyle/zerovalueunitsdisplaystrategy/show(length:).md)

## Relationships

### Conforms To

- [Decodable](swift/decodable.md)
- [Encodable](swift/encodable.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Working with zero values

- [zeroValueUnitsDisplay](swift/duration/unitsformatstyle/zerovalueunitsdisplay.md)
