谷歌日历 API 的日期格式化程序 [英] Date formatter for the google calender API
本文介绍了谷歌日历 API 的日期格式化程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
1) 我从谷歌日历获取日期.格式是 2013-05-03T22:30:00.000+02:00 像这样.应用中此类日期使用的日期格式.
1) I am getting the date from the google calender. The format is 2013-05-03T22:30:00.000+02:00 like this. Which date format used for this type of date in the app.
2) 我必须以这种格式显示日期 2013 年 2 月 4 日.
2) I have to show the date like this format Feb 4th 2013 .
如何在我的应用中实现这两个功能?请帮帮我.
How to implement these two features in the my app? Please help me.
谢谢.
推荐答案
从该字符串中获取 NSDate:
To get the NSDate from that string:
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS Z"];
NSDate *myDate = [dateFormat dateFromString:@"2013-05-03T22:30:00.000+02:00"];
一旦你有了你的 NSDate,你可以做同样的事情来获得表示:
Once you have your NSDate, you can do the same to get the representation:
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:"MMM d yyyy"];
NSString *myString = [myDate stringFromDate:myDate];
您可以在此处查阅整个日期格式选项:
You can consult the whole date formatting options here:
这篇关于谷歌日历 API 的日期格式化程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文