Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 13: Internationalization and Lo... > Formatting Numbers and Dates

Formatting Numbers and Dates

Numbers and dates are displayed differently in different locales. This is generally straightforward using NSDateFormatter and NSNumberFormatter, which you are likely already familiar with.

For an introduction to NSDateFormatter and NSNumberFormatter, see the “Data Formatting Guide” in Apple’s documentation at developer.apple.com.

There are a few things to keep in mind, however. First, formatters are needed for input as well as output. Most developers remember to use a formatter for date input, but may forget to use one for numeric input. The decimal point is not universally used to separate whole from fractional digits on input. Some countries use a comma or an apostrophe. It’s best to validate number input using an NSDateFormatter rather than custom logic.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial