在希伯来日期将数字转换为字符

时间:2013-01-10 17:36:02

标签: ios objective-c nsdate

我使用今天的日期(希伯来日期)构建标签

它的工作但是数字而不是字符

for exapmle:28/4 to 28 Tavat

代码:

NSLocale *hebrew = [[NSLocale alloc] initWithLocaleIdentifier:@"he_IL"]; // Hebrew, Israel
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSHebrewCalendar];
NSDate *today = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
dateFormat.locale = hebrew;
dateFormat.calendar = calendar;
[dateFormat setDateStyle:NSDateFormatterShortStyle];
NSString *dateString = [dateFormat stringFromDate:today];
[_label setText:dateString];

NSDateFormatter * formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterLongStyle];
[formatter setTimeStyle:NSDateFormatterNoStyle];

NSLog(@"hebrew: %@", [formatter stringFromDate:[NSDate date]]);
[formatter release];

1 个答案:

答案 0 :(得分:0)

您需要将样式更改为中等或更高:

[dateFormat setDateStyle:NSDateFormatterMediumStyle];

如果您使用中等样式,则月份将缩写,切换为完整月份名称的长样式(NSDateFormatterLongStyle)。