假設用戶當前的語言環境未希伯來語設置,那麼你需要確保的日期格式的區域設置爲希伯來語,
NSLocale *hebrew = [[NSLocale alloc] initWithLocaleIdentifier:@"he_IL"]; // Hebrew, Israel
NSDate *today = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
dateFormat.locale = hebrew;
[dateFormat setDateStyle:NSDateFormatterShortStyle];
NSString *dateString = [dateFormat stringFromDate:today];
[_label setText:dateString];
該代碼將仍然使用日曆用戶的當前區域(例如公曆)。如果你還需要希伯來語日曆,那麼你需要這個:
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;
dataFormat.calendar = calendar;
[dateFormat setDateStyle:NSDateFormatterShortStyle];
NSString *dateString = [dateFormat stringFromDate:today];
[_label setText:dateString];
תודהרבה:)!!!! – Luda
我無法閱讀希伯來文。請英語。 :) – rmaddy
只是說謝謝:)你怎麼會遇到這個問題,如果你不說希伯來語? – Luda