Skip to content

Initializer

init(date:time:locale:calendar:timeZone:capitalizationContext:)

iOS 15.0+ iPadOS 15.0+ Mac Catalyst 15.0+ macOS 12.0+ tvOS 15.0+ watchOS 8.0+
Creates a new FormatStyle with the given configurations.
init(date: Date.FormatStyle.DateStyle? = nil, time: Date.FormatStyle.TimeStyle? = nil, locale: Locale = .autoupdatingCurrent, calendar: Calendar = .autoupdatingCurrent, timeZone: TimeZone = .autoupdatingCurrent, capitalizationContext: FormatStyleCapitalizationContext = .unknown)

Parameters

date

The date style for formatting the date.

time

The time style for formatting the date.

locale

The locale to use when formatting date and time values.

calendar

The calendar to use for date values.

timeZone

The time zone with which to specify date and time values.

capitalizationContext

The capitalization formatting context used when formatting date and time values.

Discussion

Note

Always specify the date style, time style, or the date components to be included in the formatted string with the symbol modifiers. Otherwise, an empty string will be returned when you use the instance to format a Date.