What is the Objective-C equivalent of the Java TimeZone class?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
NSTimeZone, I believe. Can’t say I’ve ever done any Objective-C myself, but it looks right…Apple also has a (pretty short) article on using it.
It’s quite likely that they won’t be direct equivalents in every respect, of course… but if there’s something you would use with Java’s
TimeZonewhich you can’t figure out inNSTimeZone, ask about that specific call… and someone else can help you, I’m sure 🙂EDIT: The purpose of a time zone class is to convert between local times in different time zones. For example, right now, it’s 7.50pm for me – but it’s 12.50pm for the person who I’m about to have a Skype call with. One option for representing dates and times is to always store them in UTC (which is sort of the “zero” of time zones) and then convert the UTC value into the “local” time for the user, e.g. for display purposes. That’s not always the right option, but it’s usually a good starting point.
At other times, you may have a local time and know person X’s time zone – and want to convert it to person Y’s time zone. It’s usually easiest to do that by converting the local time to UTC (using X’s time zone) and then to convert it back to local time using Y’s time zone.
Time zones aren’t nearly as straightforward as you might expect – mostly due to daylight savings. Oddities:
The list goes on.