• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSDateFormatter strangeness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDateFormatter strangeness


  • Subject: Re: NSDateFormatter strangeness
  • From: Simon Wolf <email@hidden>
  • Date: Tue, 18 Nov 2008 17:28:24 +0000

On 18 Nov 2008, at 17:06, Greg Hoover wrote:

Ok, I buy that, but then what's the problem here:

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat: @"dd/MM/YYYY"];
NSString *str = @"3/10/2008";
NSLog(@"%@\r%@\r%@", str, [formatter dateFromString: str], [formatter stringFromDate: [formatter dateFromString: str]]);
[formatter release];


This code uses the formatter both directions but prints out the following:

3/10/2008
2007-12-23 00:00:00 -0800
23/12/2007

So it's clear that there is a problem converting from the string to date. Is there an issue with creating static NSDateFormatters? Its curious because some of the date formatters in my app work as expected, others do not.

Set your date format string to "dd/MM/yyyy"

[formatter setDateFormat: @"dd/MM/yyyy"];

Simon Wolf

Cocoa Blog: http://www.ottersoftware.com/developer//developer/
Twitter: http://www.twitter.com/sgaw
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSDateFormatter strangeness
      • From: Greg Hoover <email@hidden>
References: 
 >NSDateFormatter strangeness (From: Greg Hoover <email@hidden>)
 >Re: NSDateFormatter strangeness (From: "Kyle Sluder" <email@hidden>)
 >Re: NSDateFormatter strangeness (From: Greg Hoover <email@hidden>)
 >Re: NSDateFormatter strangeness (From: Nathan Kinsinger <email@hidden>)
 >Re: NSDateFormatter strangeness (From: Greg Hoover <email@hidden>)

  • Prev by Date: Re: CMGetImageSpace() replacement?
  • Next by Date: Re: NSDateFormatter strangeness
  • Previous by thread: Re: NSDateFormatter strangeness
  • Next by thread: Re: NSDateFormatter strangeness
  • Index(es):
    • Date
    • Thread