descriptionWithCalendarFormat:timeZone:locale:
日付オブジェクトを文字列にして返します
-(NSString *)descriptionWithCalendarFormat:(NSString *)formatString:
timeZone:(NSTimeZone *)aTimeZone:
locale:(NSDictionary *)localeDictionary:
解説
日付オブジェクト(NSDate)をフォーマットしてローカライズした文字列にして返します。
%1mとすると1桁表示にできます
返り値
( NSString * )
文字列
引数
( NSString * )formatString
フォーマット文字列
( NSTimeZone * )aTimeZone
( NSDictionary * )localeDictionary
ローカライズ辞書
フレームワーク
Foundation
クラス
NSDate
Instance Methods
使用可能
10.0
参照
- description
- descriptionWithCalendarFormat:locale:(NSCalendarDate)
-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]; NSDate *theDate; theDate = [NSDate date]; [myOutlet setStringValue:[theDate descriptionWithCalendarFormat:@"%y/%m/%d (%A) %I:%M %p" timeZone:[NSTimeZone timeZoneWithAbbreviation:@"JST"] locale:dic]]; } @end