将公历月和日的名称更改为伊斯兰? NSDate [英] Changing Gregorian Month and Days names to Islamic? NSDate
本文介绍了将公历月和日的名称更改为伊斯兰? NSDate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试显示伊斯兰语的当前day
名称,month
名称.我使用NSLocale将区域设置为ar_SA
,但是它只是将日期和月份的名称从英语翻译为阿拉伯语.
I'm trying to display the Islamic current day
name , month
name. I used NSLocale to set the region to ar_SA
, however it's just translating the day and month names from English to Arabic.
输出我用阿拉伯语输入:
Output I'm getting in Arabic:
١٢ الأحد ، اكتوبر ، ٢٠١٢
,英语为Sunday, October 28, 2012
我想要的输出:
Al-Ahad, Dul-Hijja 12, 1433
摘要:
NSDateFormatter *islamicFormatter = [[NSDateFormatter alloc]init];
[islamicFormatter setDateStyle:NSDateFormatterFullStyle];
[islamicFormatter setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"ar_SA"]];
NSString *islamicDateString = [islamicFormatter stringFromDate:islamicDate];
NSLog(@"%@",islamicDateString);
我希望对你们来说很清楚.
I hope it's clear for you guys.
推荐答案
我认为这会有所帮助
NSCalendar * hijri = [[NSCalendar alloc] initWithCalendarIdentifier:NSIslamicCalendar];
NSDateFormatter * formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterLongStyle];
[formatter setTimeStyle:NSDateFormatterNoStyle];
[formatter setCalendar:hijri];
NSLog(@"hijri: %@", [formatter stringFromDate:[NSDate date]]);
[formatter release];
这篇关于将公历月和日的名称更改为伊斯兰? NSDate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文