公历到希伯来语
如何将公历日期转换为等效的希伯来日期? 另外请告诉我这些日历,因为我对此了解不多。
How to convert a gregorian date into the equivalent hebrew date?
Also please tell about these calendars as I am not having much knowledge of these.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个方便的类,名为 <代码>NSCalendar。您可以这样创建一个:
一旦获得了日历对象,您就可以使用它们将日期转换为各种表示形式:
在我的机器上,此日志:
如果您想将内容转换为更易读的格式,您可以使用 < a href="http://developer.apple.com/library/ios/#documentation/cocoa/reference/Foundation/Classes/NSDateFormatter_Class/Reference/Reference.html" rel="noreferrer">
NSDateFormatter
:此日志:
看起来
NSDateFormatter
正在使用公历日期,但至少它有正确的月份名称,对吗?编辑
实际上,我搞砸了。如果您只是设置
NSDateFormatter
的日历,则根本不必担心日期转换。请参阅:此日志:
好多了!可可不是很棒吗?
There's a handy class called
NSCalendar
. You create one like this:Once you've got the calendar objects, you can use them to convert a date around to various representations:
On my machine, this logs:
If you want to convert stuff to a more readable format, you use
NSDateFormatter
:This logs:
It would appear that
NSDateFormatter
is using the gregorian date, but at least it's got the right month name, right?edit
Actually, I goofed. If you just set the calendar of the
NSDateFormatter
, you don't have to worry about converting the date at all. See:This logs:
Much better! Isn't Cocoa awesome?