localizedString(from:unitsStyle:)
Returns a localized string based on the specified date components and style option.
Declaration
class func localizedString(from components: DateComponents, unitsStyle: DateComponentsFormatter.UnitsStyle) -> String?Parameters
- components:
The value to format.
- unitsStyle:
The style for the resulting units. Use this parameter to specify whether you want to the resulting string to use an abbreviated or more spelled out format.
Return Value
A string containing the localized date and time information.
Discussion
Use this convenience method to format a string using the default formatter values, with the exception of the unitsStyle value.