内容简介:我想知道是否可以在NSCateendar对象上设置时区,用于从NSDateComponents创建NSDate.我没有尝试过这个,不知道是否可以工作,但这可能值得一试.http://stackoverflow.com/questions/3655616/setting-an-nsdate-to-specific-date-time-and-timezone
我需要将NSDate设置为iPhone App的特定日期,时间和时区.
下面的示例代码在iOS 4上可以正常工作,因为setTimeZone与iOS 4一起引入.如何在不使用setTimeZone的情况下轻松将NSDate设置为日期,时间和时区,以便它可以在iOS 3.0设备上使用?
NSDateComponents *comps = [[NSDateComponents alloc] init]; [comps setYear:2010]; [comps setMonth:8]; [comps setDay:24]; [comps setHour:17]; [comps setMinute:5]; [comps setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"] ]; NSCalendar *cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDate *referenceTime = [cal dateFromComponents:comps];
猜猜这应该很简单,但不知何故NSDate,组件和日历和我不是好朋友…
我想知道是否可以在NSCateendar对象上设置时区,用于从NSDateComponents创建NSDate.我没有尝试过这个,不知道是否可以工作,但这可能值得一试.
http://stackoverflow.com/questions/3655616/setting-an-nsdate-to-specific-date-time-and-timezone
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- java – 如何使用Apache CXF来表示没有时区的日期?
- Ghost 1.24.6 发布,修复时区更改时的日期网址问题
- Parallels Desktop虚拟机里的时区/时钟与Mac OS时区不同步
- Linux下修改时区
- perl 国际时区设置
- Swift的时区处理
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Data Structures and Algorithm Analysis in Java
Mark A. Weiss / Pearson / 2006-3-3 / USD 143.00
As the speed and power of computers increases, so does the need for effective programming and algorithm analysis. By approaching these skills in tandem, Mark Allen Weiss teaches readers to develop wel......一起来看看 《Data Structures and Algorithm Analysis in Java》 这本书的介绍吧!