Friday, May 10, 2013

NSDateFormatter defaultFormatterBehavior example ios


defaultFormatterBehavior

Returns the default formatting behavior for instances of the class.
+ (NSDateFormatterBehavior)defaultFormatterBehavior
Return Value
The default formatting behavior for instances of the class. For possible values, seeNSDateFormatterBehavior.
Discussion of [NSDateFormatter defaultFormatterBehavior]
For iOS and for OS X applications linked against OS X v10.5 and later, the default isNSDateFormatterBehavior10_4.
Example of [NSDateFormatter defaultFormatterBehavior]
- (void) setHeaderText
{
    NSDateFormatter* formatter = [NSDateFormatter defaultFormatterBehavior];
    [formatter setDateFormat: @"MMMM"];
    headerText.text = [NSString stringWithFormat:
        @"Summary for (%@)", [dateFormat stringFromDate: [NSDate date]]];
}
Example of [NSDateFormatter defaultFormatterBehavior]
    NSString *dateString = @"03/07/2008";
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setFormatterBehavior:[NSDateFormatter defaultFormatterBehavior]];
    [formatter setDateFormat:@"dd/MM/yyyy"];
    [formatter setLocale:[NSLocale currentLocale]];
    [formatter setTimeZone:[NSTimeZone systemTimeZone]];
    NSDate *dateFromString = [formatter dateFromString:dateString];
    [formatter release];