Search Results

Search found 73 results on 3 pages for 'nsdateformatter'.

Page 1/3 | 1 2 3  | Next Page >

  • Instruments (Leaks) and NSDateFormatter

    - by Cal
    When I run my iPhone app with Instruments Leaks and parse a bunch of NSDates using NSDateFormatter my memory goes up about 1mb and stays even though these NSDates should be dealloc'd after the parsing (I just discard them if they aren't new). I thought the malloc (in my heaviest stack trace below) could become part of the NSDate but I also thought it could be memory that only used during some intermediate step in parsing. Does anyone know which one it is or how to find out? Also, is there a way to put a breakpoint on NSDate dealloc to see if that memory is really being reclaimed? Here's what my date formatter looks like for parsing these dates: df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"EEE, d MMM yyyy H:m:s z"]; Here's the Heaviest Stack trace when the memory bumps up and stays there: 0 libSystem.B.dylib 208.80 Kb malloc 1 libicucore.A.dylib 868.19 Kb icu::ZoneMeta::getSingleCountry(icu::UnicodeString const&, icu::UnicodeString&) 2 libicucore.A.dylib 868.66 Kb icu::ZoneMeta::getSingleCountry(icu::UnicodeString const&, icu::UnicodeString&) 3 libicucore.A.dylib 868.67 Kb icu::ZoneMeta::getSingleCountry(icu::UnicodeString const&, icu::UnicodeString&) 4 libicucore.A.dylib 868.67 Kb icu::DateFormatSymbols::initZoneStringFormat() 5 libicucore.A.dylib 868.67 Kb icu::DateFormatSymbols::getZoneStringFormat() const 6 libicucore.A.dylib 868.67 Kb icu::SimpleDateFormat::subParse(icu::UnicodeString const&, int&, unsigned short, int, signed char, signed char, signed char*, icu::Calendar&) const 7 libicucore.A.dylib 868.67 Kb icu::SimpleDateFormat::parse(icu::UnicodeString const&, icu::Calendar&, icu::ParsePosition&) const 8 libicucore.A.dylib 868.67 Kb icu::DateFormat::parse(icu::UnicodeString const&, icu::ParsePosition&) const 9 libicucore.A.dylib 868.67 Kb udat_parse 10 CoreFoundation 868.67 Kb CFDateFormatterGetAbsoluteTimeFromString 11 CoreFoundation 868.67 Kb CFDateFormatterCreateDateFromString 12 Foundation 868.67 Kb -[NSDateFormatter getObjectValue:forString:range:error:] 13 Foundation 868.75 Kb -[NSDateFormatter getObjectValue:forString:errorDescription:] 14 Foundation 868.75 Kb -[NSDateFormatter dateFromString:] Thanks!

    Read the article

  • return nil for dateFromString call of NSDateFormatter

    - by tw
    I am getting nil returned for the date variable in the below code. I can't find any problem with the date format, can anyone help? NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"EEE MMM dd HH:mm:ss zzz yyyy"]; NSString *dateString = [[NSString alloc] initWithFormat:@"%@", @"Mon Apr 05 04:37:28 UTC 2010"]; NSDate *date = [formatter dateFromString:dateString];

    Read the article

  • NSDateFormatter problem

    - by jeeva
    I am trying to get NSDate from string but its returning nil. I tried this: NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy-mm-dd'T'HH:mm:ss'Z'"]; NSDate *date = [dateFormatter dateFromString:@"2010-05-07T10:12:32UTC"]; NSLog(@"Success date=%@",[date description]); Thanks

    Read the article

  • NSDateFormatter always return 2010-12-31 23:00:00 +0000

    - by Janky
    Hello! I'm using this code to format a date from a string: NSDateFormatter *dateFormat = [[NSDateFormatter alloc]init]; [dateFormat setDateFormat:@"EEEE, dd MMMM yyyy"]; NSDate *dateStart = [dateFormat dateFromString:[thisEvent dateEvent]]; [thisEvent dateEvent] contains this date: Saturday, 09 April 2011 I don't know why dateStart contains 2010-12-31 23:00:00 +0000 where I'm wrong? Thank You!!

    Read the article

  • iPhone NSDateFormatter Timezone Conversion

    - by MobileDeveloperTips
    I am trying to create a formatter that will convert the date format shown to an NSDate object: NSString *dateStr = @"2010-06-21T19:00:00-05:00"; NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZ"]; NSDate *date = [dateFormat dateFromString:dateStr]; The issue is the timezone -05:00, which is not parsed properly with the format above. Any suggestions?

    Read the article

  • Date from String using NSDateFormatter regardless 12h-24h setting

    - by maxf99
    Hello everybody, Today my question is about date formats and strings. My application downloads some strings representing dates from the internet. The date format is always like this: "2010-05-24 at 20:45" I need to convert this string into an NSDate object in order to perform some date manipulations. I tried this code: NSString * dateString = @"2010-05-24 at 20:45" // actually downloaded from the internet NSDateFormatter * myDateFormatter = [[NSDateFormatter alloc] init]; [myDateFormatter setDateFormat:@"yyyy-MM-dd 'at' HH:mm"]; NSDate * dateFromString = [myDateFormatter dateFromString:dateString]; This seems to work perfectly fine as long as the iPhone is set to 24h clock. As long as I switch to 12h clock in the general settings the NSDate object is not created (and the application happily crashes) I have read others having similar problems but I don't seem to find a solution. Now the questions: It doesn't make sense to me that the NSDateFormatter is sensible to user settings as long as I am specifying which format it is supposed to use to parse the string (which is not modifiable because it comes from the web), what's the use of checking user settings? More important, how can I get my task performed (to get an NSDate object from the string regardless the user settings)?

    Read the article

  • Displaying timecode using NSTimer and NSDateFormatter

    - by Chris B
    Hi. I am very close to completing my first iphone app and it has been a joy. I am trying to add running timecode using the current time via an NSTimer displaying the current time (NSDate) on a UILabel. NSDate is working fine for me, showing hour, minute, second, milliseconds. But instead of milliseconds, I need to show 24 frames per second. The problem is that I need the frames per second to be synced 100% with the hour, minute and second, so I can't add the frames in a separate timer. I tried that and had it working but the frame timer was not running in sync with the date timer. Can anyone help me out with this? Is there a way to customize NSDateFormatter so that I can have a date timer formatted with 24 frames per second? Right now I'm limited to formatting just hours, minutes, seconds, and milliseconds. Here's the code I'm using right now -(void)runTimer { // This starts the timer which fires the displayCount method every 0.01 seconds runTimer = [NSTimer scheduledTimerWithTimeInterval: .01 target: self selector: @selector(displayCount) userInfo: nil repeats: YES]; } //This formats the timer using the current date and sets text on UILabels - (void)displayCount; { NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease]; NSDate *date = [NSDate date]; // This will produce a time that looks like "12:15:07:75" using 4 separate labels // I could also have this on just one label but for now they are separated // This sets the Hour Label and formats it in hours [formatter setDateFormat:@"HH"]; [timecodeHourLabel setText:[formatter stringFromDate:date]]; // This sets the Minute Label and formats it in minutes [formatter setDateFormat:@"mm"]; [timecodeMinuteLabel setText:[formatter stringFromDate:date]]; // This sets the Second Label and formats it in seconds [formatter setDateFormat:@"ss"]; [timecodeSecondLabel setText:[formatter stringFromDate:date]]; //This sets the Frame Label and formats it in milliseconds //I need this to be 24 frames per second [formatter setDateFormat:@"SS"]; [timecodeFrameLabel setText:[formatter stringFromDate:date]]; }

    Read the article

  • NULL value when using NSDateFormatter

    - by David A Gibson
    Hello, I am using the following code to try and display in a time in a table cell. TimeSlot *timeSlot = [timeSlots objectAtIndex:indexPath.row]; NSDateFormatter *timeFormat = [[NSDateFormatter alloc] init]; [timeFormat setDateFormat:@"%1m/%1d/%Y"]; NSLog(@"Time: %@", timeSlot.time); NSDate *mydate = timeSlot.time; NSLog(@"Time: %@", mydate); NSString *theTime = [timeFormat stringFromDate:mydate]; NSLog(@"Time: %@", theTime); The log output is this: 2010-04-14 10:23:54.626 MyApp[1080:207] Time: 2010-04-14T10:23:54 2010-04-14 10:23:54.627 MyApp[1080:207] Time: 2010-04-14T10:23:54 2010-04-14 10:23:54.627 MyApp[1080:207] Time: (null) I am new to developing for the iPhone and as it all compiles with no errors or warnings I am at a loss as to why I am getting NULL in the log. Is there anything wrong with this code? Thanks

    Read the article

  • NSDateFormatter dateFromString for 24hr date gives wrong time

    - by krusty
    I want to add event to native calender.I am having problem in getting date accurate time from string. I have set locale,24 hr format. but still getting the same bug. EKEvent *event = [EKEvent eventWithEventStore:self.eventStore]; event.title=txtTitle.text; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; NSLocale *locale =[[[NSLocalealloc]initWithLocaleIdentifier:@"en_US_POSIX"]autorelease]; [dateFormatter setLocale:locale]; [dateFormatter setDateFormat:@"dd/MM/yyyy HH:mm"]; event.startDate=[dateFormatter dateFromString:lblStartDate.text]; My lblStartDate.text is:-10/02/2011 12:12 PM And event.startDate is getting set as:-2011-02-10 06:42:00 GMT Can anyone help???

    Read the article

  • NULL value when using NSDateFormatter after setting NSDate property via XML parsing

    - by David A Gibson
    Hello, I am using the following code to try and display in a time in a table cell. TimeSlot *timeSlot = [timeSlots objectAtIndex:indexPath.row]; NSDateFormatter *timeFormat = [[NSDateFormatter alloc] init]; [timeFormat setDateFormat:@"HH:mm:ss"]; NSLog(@"Time: %@", timeSlot.time); NSDate *mydate = timeSlot.time; NSLog(@"Time: %@", mydate); NSString *theTime = [timeFormat stringFromDate:mydate]; NSLog(@"Time: %@", theTime); The log output is this: 2010-04-14 10:23:54.626 MyApp[1080:207] Time: 2010-04-14T10:23:54 2010-04-14 10:23:54.627 MyApp[1080:207] Time: 2010-04-14T10:23:54 2010-04-14 10:23:54.627 MyApp[1080:207] Time: (null) I am new to developing for the iPhone and as it all compiles with no errors or warnings I am at a loss as to why I am getting NULL in the log. Is there anything wrong with this code? Thanks Further Info I used the code exactly from your answer lugte098 just to check and I was getting dates which leads me to believe that my TimeSlot class can't have a date correctly set in it's NSDate property. So my question becomes - how from XML do I set a NSDate property? I have this code (abbreviated): -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *) string { if ([currentElement isEqualToString:@"Time"]) { currentTimeSlot.time = string } } Thanks

    Read the article

  • Problem with NSDateformatter

    - by Nithin
    Hi all, i've seen many questions on NSDateformatter and NSDate, but none could help me out. [formatter setDateFormat:@"yyyy/mm/dd"]; NSDate *date = [formatter dateFromString:@"2010/03/10"]; if (date) { NSLog(@"Date returned:::%@",date); return date; } The Probelm is that, its returning the date --- '2010-01-10 00:03:00 +0600' The month is changed to 1 and the minute to 3, What might be the problem???

    Read the article

  • What's wrong with how I'm using NSDateFormatter?

    - by Thom Mahoney
    dateFormatter = [[NSDateFormatter alloc] init]; dateFormatter.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]; [dateFormatter setDateFormat:@"EEE, d MMM yyyy HH:mm:ss zzz"]; NSString dateString = @"Tue, 08 Jun 2010 17:00:00 EDT"; NSDate eventDate = [dateFormatter dateFromString:dateString]; In this case the eventDate object is nil. Can somebody clue me in? This code used to work.

    Read the article

  • Unable to Parse Date using NSDateFormatter

    - by Ansari
    Hi, I am fetching a RSS, in which i receive the following Date stamp: 2010-05-10T06:11:14.000Z Now i am using NSDateFormatter to parse this datetime stamp. [parseFormatter setDateFormat:@"yyyy-MM-dTH:m:s.z"]; But its not working fine if just remove the time stamp part it works for the date [parseFormatter setDateFormat:@"yyyy-MM-d"]; But if i add the rest of the stuff it returns nil. Any idea ? Thanks in Advance....

    Read the article

  • NSDateFormatter - set device language as locale?

    - by Emil
    Hey. I'm trying to get the iPhone to display dates formatted by an NSDateFormatter in the current device language. I have tried setLocale:[NSLocale currentLocale], but that only returns 5 instead of May (or Mai, as I want it to be). Any help is appreciated. Thanks! :)

    Read the article

  • NSDateFormatter incorrect date on simulator, correct date on device

    - by Rudiger
    Hi, Im building a calendar and to find out the first day of the month I do [formatter setDateFormat:@"e"]; int startDay = [[formatter stringFromDate:newDate] intValue]; On the device this works correctly and the 1st of the month is on the correct day. But on the simulator it is the day after. Although it doesn't overly matter about the simulator it is kind of driving me crazy thinking I've done something wrong. I tried to set the locale of the formatter but no difference, nor i think should it. Can anyone shed some light on this? On a side note is there a better way to build a calendar than this?

    Read the article

  • NSDateFormatterFullStyle without year (NSDateFormatter)

    - by Brian Halpin
    Using the user's currentLocale from the device, I want to have a date format exactly like the one generated for NSDateFormatterFullStyle minus the year: [dateFormatter setDateStyle:NSDateFormatterFullStyle]; Friday, 21 September (2012) I've noticed the iPhone app, Living Earth does this and works for all locales, so does the iPhone lock screen. A custom formatter such as, [dateFormatter setDateFormat:@"EEEE, MMMM"]; won't change with localisation. Can anyone shed some light on how to accomplish this? None of the options for date style seem to do this. Thanks

    Read the article

  • Remove year component from NSDateFormatter style

    - by JK
    I would like to present a date in the kCFDateFormatterFullStyle, but without the year. Is there any way to remove the year component from this style? My app requires localization so practically I cannot programmatically set the format string for all locales. I have come accross a solution which removes the "y" characters from the format string returned by the built in styles. Unfortunately, this is not acceptable as the year components are not represented by "y" in some other languages like Japanese. Any suggestions to get the kCFDateFormatterFullStyle without the year would be great! Thanks.

    Read the article

  • NSDateFormatter iOS6 issue

    - by Angad Manchanda
    I have written a code for UIButton press to decrement date. The present date is shown in a UILabel text property and it changes to the previous date when the button is pressed. The following code works perfectly fine for iOS5 but doesn't work with iOS6. With iOS6, it gives the output as Dec 31, 1999 or null. - (IBAction)showPrevDate:(id)sender { NSString *dateForDecrement = _showDateLbl.text; [dateFormatter setDateFormat:@"MMM d, yyyy (EEE)"]; NSDate *dateObjectForDecrement = [dateFormatter dateFromString:dateForDecrement]; int subtractDays = 1; dateAfterDecrement=[dateObjectForDecrement dateByAddingTimeInterval:-(24*60*60 * subtractDays)]; _showDateLbl.text = [NSString stringWithFormat:@"%@", [dateFormatter stringFromDate:dateAfterDecrement]]; } Can anybody verify this, or tell me if its's a bug in iOS6 ? Thanks guys.

    Read the article

  • NSDateFormatter Puzzle! Is this is new Mountain Lion Bug?

    - by user1631526
    I believe I might have found a bug in NSDateFormatter, and I am not sure if this is localized to Brazil date format. This is my resulting log: 2012-08-26 01:32:17.875 nsDateFormatterPuzzle[3261:303] original item # 0 = 2011-09-18 2012-08-26 01:32:17.876 nsDateFormatterPuzzle[3261:303] original item # 1 = 2011-10-16 2012-08-26 01:32:17.876 nsDateFormatterPuzzle[3261:303] original item # 2 = 2011-11-13 2012-08-26 01:32:17.877 nsDateFormatterPuzzle[3261:303] original item # 3 = 2011-12-11 2012-08-26 01:32:17.877 nsDateFormatterPuzzle[3261:303] original item # 4 = 2012-01-08 2012-08-26 01:32:17.877 nsDateFormatterPuzzle[3261:303] original item # 5 = 2012-02-05 2012-08-26 01:32:17.883 nsDateFormatterPuzzle[3261:303] formatted item # 0 = 18/09/2011 2012-08-26 01:32:17.884 nsDateFormatterPuzzle[3261:303] formatted item # 1 = (null) 2012-08-26 01:32:17.885 nsDateFormatterPuzzle[3261:303] formatted item # 2 = 13/11/2011 2012-08-26 01:32:17.886 nsDateFormatterPuzzle[3261:303] formatted item # 3 = 11/12/2011 2012-08-26 01:32:17.887 nsDateFormatterPuzzle[3261:303] formatted item # 4 = 08/01/2012 2012-08-26 01:32:17.887 nsDateFormatterPuzzle[3261:303] formatted item # 5 = 05/02/2012 Note that if you go to System Preferences -- Date and Time -- Time Zone and change your Time Zone to Rio de Janeiro, you will have the same results.

    Read the article

  • my NSDateFormatter works only in the iPhone simulator

    - by Manuel Spuhler
    I use a NSDateFormatter which works fine in the simulator, but I get a nil when I run it in the iPhone. I hardcoded the date to be sure of the format, but it fails anyway. NSString *strPubDate = @"Fri, 8 May 2009 08:08:35 GMT"; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; [dateFormatter setDateFormat:@"EEE, d MMM yyyy HH:mm:ss Z"]; NSDate *myDate = [dateFormatter dateFromString:strPubDate]; I tried with different region settings, languages etc. on the iPhone. Any idea what is going wrong?

    Read the article

  • NSDateFormatter

    - by srushti
    my code is like this NSString *tempDate = [NSString stringWithString:tempReviewData.pubDate]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateStyle:NSDateFormatterLongStyle]; [dateFormatter setTimeStyle:NSDateFormatterNoStyle]; [dateFormatter setDateFormat:@"HH:mm a"]; NSDate *newDate = [dateFormatter dateFromString:tempReviewData.pubDate]; My newDate is getting nil at this point i dont know why

    Read the article

  • iPhone SDK NSString To NSDate

    - by disp
    I got a string from parsing a XML file which looks like this: Fri, 09 Apr 2010 00:00:45 +0200 and the corresponding pattern should be this "EEE, dd MMM yyyy HH:mm:ss ZZ", but I get (null). This is my code: NSString *dateString = @"Fri, 09 Apr 2010 00:00:45 +0200"; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss ZZ"]; NSDate *date = [dateFormatter dateFromString:dateString]; NSLog(@"date:%@",date); // result date:(null) Edit: This works for me now, I had to switch to en-US locale: NSLocale* usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en-US"]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setLocale:usLocale]; [dateFormatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss ZZ"]; NSDate *date = [dateFormatter dateFromString:dateString];

    Read the article

  • How to give a input date format in iphone

    - by Pugal Devan
    Hi, i am new to iphone development. In my input date format is "2010-03-05T18:20:40Z", and i donno to how to give a input format of my code.So i have mentioned in my code (?). input date format = "2010-03-05T18:20:40Z" Here my code is: NSString *indate = @"2010-03-05T18:20:40Z"; NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init]; [inputFormatter setDateFormat:@"????????????????????????"]; NSDate *inputDate = [inputFormatter dateFromString:indate]; NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init]; [outputFormatter setDateFormat:@"EEE. MMM. d, yyyy"]; NSString *outputDate = [outputFormatter stringFromDate:inputDate]; lDate.text = outputDate; Plz help me out. Thanks.

    Read the article

  • NSDateFormatter Does not convert correctly

    - by deamonsarea
    Hi, I have a NSString which is passed from an xml feed........ NSString *strDate =@"Thu, 22 Apr 2010 10.30 am CEST"; I'm currently using this code to format the date........ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"EEE, dd MMM yyyy hh:mm a vvvv"]; NSDate *myDate = [dateFormatter dateFromString:date]; [dateFormatter setDateFormat:@"HH"]; NSLog(@"%@", [dateFormatter stringFromDate:myDate]); I want to format my string only to display only hours and currently I'm getting value like this. strDate =@"2010-04-10 14:00:00 +0530"; Can anyone please help me with this?......

    Read the article

1 2 3  | Next Page >