0

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

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

例如:28/4 至 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];
4

1 回答 1

0

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

[dateFormat setDateStyle:NSDateFormatterMediumStyle];

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

于 2013-01-10T17:45:26.207 回答