Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8893431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:14:47+00:00 2026-06-14T23:14:47+00:00

I am always getting a null from the date formatter. I tried examples in

  • 0

I am always getting a null from the date formatter. I tried examples in all the other questions and didn’t help.

 NSLog(@"Date is %@", summaryItem.SubmittedDate);
NSLog(@"Formatted Date is %@", [df stringFromDate: summaryItem.SubmittedDate ]);
BOOL isDate = [summaryItem.SubmittedDate isKindOfClass: [NSDate class]];
NSLog(@"Date %@ a date.", isDate ? @"is" : @"is not");

Looking at the definition of SubmittedDate you have

@property (nonatomic, retain) NSDate *SubmittedDate;

I am initializing the Date Fomatter as so

- (void) initDateFormatter {
  if( df == nil ) {
    df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"MM/dd/yyyy"];
    [df setDateStyle:NSDateFormatterShortStyle];
  }
}
  1. Output to Log:
    • 2012-11-21 10:00:41.650 Mobile_v2[4093:f803] Date is 11/21/2012 10:00:41 AM
    • 2012-11-21 10:00:41.651 Mobile_v2[4093:f803] Formatted Date is (null)
    • 2012-11-21 10:00:41.681 Mobile_v2[4093:f803] Date is not a date.

Can anyone see what’s wrong? Is my date format incorrect?

Code in my SBJson class

NSString *newDate = (NSString *)[receivedObjects objectForKey:@"SubmittedDate"];
NSDate *submittedDate = [df dateFromString:newDate];  //(NSDate *) 
if ((NSNull *) submittedDate == [NSNull null]) {
    self.SubmittedDate = nil;
} else {
    self.SubmittedDate = submittedDate;
}

Actual value is “11/21/2012 10:47:54 AM”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:14:49+00:00Added an answer on June 14, 2026 at 11:14 pm

    From your log summaryItem.SubmittedDate object is not of class NSDate.

    First log the class of that object,

    NSLog(@"%@",  [summaryItem.SubmittedDate class]);
    

    if the output is not NSDate, there is something wrong in implementation (.m file) in the class where
    @property (nonatomic, retain) NSDate *SubmittedDate; is declared.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to retrive data from my table. But it always returns (null).
I have a problem with getting text from selected position of JComboBox. I tried
When i call f_CategoriNewsGet function from Page_Load method I'm getting null. But i can
am trying send an array to php file using $_POST ,still always getting an
I am trying to generate struts 2 modular archetype using maven but always getting
I seem to be getting this particular always when i am trying to receive
Designing forms has always been fun, but getting them to send email on the
I've been using HttpWebRequest/HttpWebResponse lately and I'm getting encoding problems. HttpWebResponse.CharacterSet doesn't always represent
I always seen on SyncLock examples people using Private Lock1 As New Object '
The always interesting issue of NULL Vs Blank is driving me bit crazy now.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.