descriptionWithCalendarFormat:locale:
カレンダー日付を書式指定してローカライズした文字列で返します
-(NSString *)descriptionWithCalendarFormat:(NSString *)format:
locale:(NSDictionary *)locale:
解説
カレンダー日付を書式指定してローカライズした文字列で返します。
【locale】ローカライズされた日付の名称の辞書
● NSTimeDateFormatString 「曜日、月、日、時刻、時差、年」
● NSAMPMDesignation 午前/午後を表す配列(NSArray)
● NSMonthNameArray 1月から12月までの月の名前を表す配列(NSArray)
● NSShortMonthNameArray 1月から12月までの省略形の月の名前を表す配列(NSArray)
● NSWeekDayNameArray 曜日の名前を表す配列(NSArray)
● NSShortWeekDayNameArray 省略形の曜日の名前を表す配列(NSArray)
返り値
( NSString * )
文字列
引数
( NSString * )format
フォーマット
( NSDictionary * )locale
場所
フレームワーク
Foundation
クラス
NSCalendarDate
Instance Methods
使用可能
10.0
参照
- description
- descriptionWithCalendarFormat:
- descriptionWithLocale:
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { /* Localizable.stringsのJapaneseに記入してあります。 "sun"="日曜日"; "mon"="月曜日"; "tue"="火曜日"; "wed"="水曜日"; "thu"="木曜日"; "fri"="金曜日"; "sat"="土曜日"; "january_old"="睦月"; "february_old"="如月"; "march_old"="弥生"; "april_old"="卯月"; "may_old"="皐月"; "june_old"="水無月"; "july_old"="文月"; "august_old"="葉月"; "september_old"="長月"; "october_old"="神無月"; "november_old"="霜月"; "december_old"="師走"; "gozen"="午前"; "gogo"="午後"; */ NSArray *month = [NSArray arrayWithObjects: NSLocalizedString(@"january_old",@"1"), NSLocalizedString(@"february_old",@"2"), NSLocalizedString(@"march_old",@"3"), NSLocalizedString(@"april_old",@"4"), NSLocalizedString(@"may_old",@"5"), NSLocalizedString(@"june_old",@"6"), NSLocalizedString(@"july_old",@"7"), NSLocalizedString(@"august_old",@"8"), NSLocalizedString(@"september_old",@"9"), NSLocalizedString(@"october_old",@"10"), NSLocalizedString(@"november_old",@"11"), NSLocalizedString(@"december_old",@"12"), nil]; NSArray *week = [NSArray arrayWithObjects: NSLocalizedString(@"sun",@""), NSLocalizedString(@"mon",@""), NSLocalizedString(@"tue",@""), NSLocalizedString(@"wed",@""), NSLocalizedString(@"thu",@""), NSLocalizedString(@"fri",@""), NSLocalizedString(@"sat",@""), nil]; NSArray *ampm = [NSArray arrayWithObjects: NSLocalizedString(@"gozen",@""), NSLocalizedString(@"gogo",@""), nil]; NSDictionary *dic= [[NSDictionary alloc] initWithObjectsAndKeys: month,@"NSMonthNameArray", ampm,@"NSAMPMDesignation", week,@"NSWeekDayNameArray", nil]; NSCalendarDate *theDate; theDate = [NSCalendarDate calendarDate]; [myOutlet setStringValue:[theDate descriptionWithCalendarFormat:@"%y/%m/%d (%A) %I:%M %p" locale:dic]]; } @end