Contents

dateFormat(fromTemplate:options:locale:)

Returns a localized date format string representing the given date format components arranged appropriately for the specified locale.

Declaration

class func dateFormat(fromTemplate tmplate: String, options opts: Int, locale: Locale?) -> String?

Parameters

  • tmplate:

    A string containing date format patterns (such as “MM” or “h”).

    For full details, see 10000039i.

  • opts:

    No options are currently defined.

  • locale:

    The locale for which the template is required.

Return Value

A localized date format string representing the date format components given in template, arranged appropriately for the locale specified by locale. The returned string may not contain exactly those components given in template, but may—for example—have locale-specific adjustments applied.

Discussion

Different locales have different conventions for the ordering of date components. You use this method to get an appropriate format string for a given set of components for a specified locale (typically you use the current locale—see current).

The following example shows the difference between the date formats for British and American English:

See Also

Managing Formats and Styles