Declaration

Overview

A DateIntervalFormatter object creates user-readable strings from pairs of dates. Use a date interval formatter to create user-readable strings of the form <start> - <end> for your app’s interface, where <start> and <end> are date values that you supply. The formatter uses locale and language information, along with custom formatting options, to define the content of the resulting string. You can specify different styles for the date and time information in each date value.

To use this class, create an instance, configure its properties, and call the string(from:to:) method to generate a string. The properties of this class let you configure the calendar and specify the style to apply to date and time values. Given a current date of January 16, 2015, Configuring the Formatter Options shows how to configure a formatter object and generate the string “1/16/15 - 1/17/15”.

Always set to the dateStyle and timeStyle properties to appropriate values before generating any strings.

The string(from:to:) method may be called safely from any thread of your app. It is also safe to share a single instance of this class from multiple threads, with the caveat that you should not change the configuration of the object while another thread is using it to generate a string.

A formatter that converts between dates and their ISO 8601 string representations.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.