Search code examples
iosnsdatensdateformatter

Japanese Date Format ios


ok, straight to the point, i want to make calendar format like this

YYYY年MM月DD日

i've set my code like this

- (void)RecentStartDidSelect:(NSDate *)selectedDate element:(id)element {
    self.selectedDate = selectedDate;
    //////
    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
        [dateFormat setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:[[NSLocale preferredLanguages] objectAtIndex:0]] autorelease]];
    [dateFormat setDateFormat:@"YYYY(EEE)-MM(EEEm)-dd(EEE)"];

    NSString *theDate = [dateFormat stringFromDate:self.selectedDate];
    //may have originated from textField or barButtonItem, use an IBOutlet instead of element
    Recent_start.text = theDate;
    [Recent_start resignFirstResponder];

}

and the output is

 theDate-->2013(Wed)-02(Wed48)-06(Wed)

i'm lost now, how to create date format like that? :(( pls help


Solution

  • [dateFormatter setDateFormat:@"yyyy年MM月dd日"];
    

    That is Chinese