« Find Records Owned by Inactive User | Main | Major Improvements to DupeCatcher »

Serialize Date Fields


A few days ago a co-worker of mine came to me with a problem when working on an iOS mobile app procedure. She was developing a procedure that would upload records into her Salesforce org using SQlite queries. Upon doing so, however, she kept getting a message saying that her dates couldn’t be serialized. Before coming to me she checked with a few other folks here who suggested some other options like using ASCII notation “/” in the dates, but to no avail. After sitting with her for a minute, I realized the solution was pretty easy and now I’m sharing it with you guys. Hope this helps!


//setting the dateFormatter

    NSTimeInterval startDateSeconds = [[NSDate myDate] timeIntervalSince1970];


    NSDate *dateStart = [NSDate dateWithTimeIntervalSince1970:dateStartSeconds];


    NSDateFormatter* df_utc = [[[NSDateFormatteralloc] init] autorelease];


    [df_utc setTimeZone:[NSTimeZonetimeZoneWithName:@"UTC"]];

    [df_utc setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.000'Z'"];

    NSString *dateStartString = [df_utc stringFromDate:dateStart];

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
All HTML will be escaped. Hyperlinks will be created for URLs automatically.