Skip to content

Instantly share code, notes, and snippets.

@jessedc
Created June 7, 2012 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessedc/2887327 to your computer and use it in GitHub Desktop.
Save jessedc/2887327 to your computer and use it in GitHub Desktop.
DateFormatter stuffs
NSDateFormatter *timeOfArrival = [[NSDateFormatter alloc] init];
[timeOfArrival setTimeStyle:NSDateFormatterLongStyle];
[timeOfArrival setDateStyle:NSDateFormatterNoStyle];
[timeOfArrival setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]];
NSString *etaStr = [attributeDict objectForKey:@"cumulativeTime"];
NSLog(@"%@", etaStr);
checkpoint.eta = [timeOfArrival dateFromString:etaStr];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]];
[formatter setDateFormat:@"HH:mm:ss"];
NSString *etaStr = @"00:14:00";
NSLog(@"%@", [formatter stringFromDate:[formatter dateFromString:etaStr]]);
[formatter release];
00:14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment