Friday, May 10, 2013

NSDateFormatter setTwoDigitStartDate example ios


setTwoDigitStartDate:

Sets the two-digit start date for the receiver.
- (void)setTwoDigitStartDate:(NSDate *)date
Parameters of [NSDateFormatter setTwoDigitStartDate]
date
The earliest date that can be denoted by a two-digit year specifier.


Example of [NSDateFormatter setTwoDigitStartDate]
- (void)awakeFromNib {
    NSDate *startDate = [NSDate dateWithTimeIntervalSinceReferenceDate:0];
    //NSDate *startDate = [NSDate dateWithTimeIntervalSince1970:0];
    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
    [dateFormat setFormatterBehavior:NSDateFormatterBehavior10_4];
    [dateFormat setDateStyle:NSDateFormatterShortStyle];
    [dateFormat setTwoDigitStartDate:startDate];
    [dateFormat setLenient:YES]; // tried with & without this
    [transactionDateField setFormatter:dateFormat];
}