dateformatter 在模拟器中有效,但在设备上无效
这段代码适用于模拟器...但不适用于我的 iPod touch...在 iPod 上我看到未格式化的日期:-(
NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] retain];
//Date Before = Sun, 20 Jun 2010 06:00:00 +020
[formatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss Z"];
NSDate *d = [formatter dateFromString:string];
[formatter setDateFormat:@"dd.MM.yyyy HH:mm"];
string = [NSString stringWithString:[formatter stringFromDate:d]];
[currentDate appendString:string];
this code works on simulator ... but not on my ipod touch... on ipod I see the unformated date :-(
NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] retain];
//Date Before = Sun, 20 Jun 2010 06:00:00 +020
[formatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss Z"];
NSDate *d = [formatter dateFromString:string];
[formatter setDateFormat:@"dd.MM.yyyy HH:mm"];
string = [NSString stringWithString:[formatter stringFromDate:d]];
[currentDate appendString:string];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在设备上,您需要明确设置您的区域设置。
插入这一行:
紧接着:
On the device, you need to explicitly set your locale.
Insert this line:
Right after: