In iOS 15, we got a new Formatter API. Apple provides a new formatter across the board, numbers, dates, times, and more. Why do we need another format

New Formatters in iOS 15: Why do we need another formatter

submited by
Style Pass
2021-07-01 16:00:07

In iOS 15, we got a new Formatter API. Apple provides a new formatter across the board, numbers, dates, times, and more. Why do we need another formatter? How does it differ from the old one? Let's find out.

Practical Sign in with Apple: Learn everything you need to know about Sign in with Apple to be able to integrate it in your existing app or a new one.

Before digging into the new formatter API, I want to assure you that the old API doesn't go anywhere. The new formatter API is all about taking data, like numbers, dates, times, and more and converting it into a localized user-presentable string. What the new formatter can do is a subset of what the old formatter can.

Most formatters we have right now are not just simple formatter but converter. They can convert data to string and vice-versa. For example, DateFormatter can convert string to date and date to string.

<1> We specified a format of passing string. <2> A time zone, in this case, is GMT+7 (Bangkok timezone) <3> We use the gregorian calendar.

Leave a Comment