objective c - NSDateFormatter and date conversion not working -


I am developing an app for the iPhone where I get an XML feed from a date in just one HH: mm format Need to change.

I have the following method that does not work and I have no clue what I am doing.

As an example, the timing string will be: " Mon, 01 Feb 2010 21:55:00 +0100 " (without quotation marks)

This method works when the area is in the U.S. (I get the correct date back), but not when I change the area (settings-> General-> International) in Spain, or in other areas (in that case I do not get back).

  - (id) timeContentHHM: (NSString *) Time to Convert {NSString * newPubDate = timeToConvert; // Remove any garbage from IA code Newboot = [newPubDate stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]] ;; // Extractor format and format to convert XML string into an NSDate NSDateFormatter * originalDateFormatter = [[[NSDateFormatter alloc] init] AutoCurlus; [Original Dataform Setad Format: @ "EE, DMM Mi Yyyy H: mm: SS Z"]; // run the string through the format NSDate * formatted data = [[NSDT Alok] init]; Formatted date = [date of original date format: date-width: newpubdate]; // Now create another formatter to take NSDate and format it hours and minutes NSDateFormatter * newDateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [NewDateFormatter setDateFormat: @ "HH: mm"]; // 24h clock set // and let's change it to a readable string NSString * calcHHMM = [newDateFormatter stringFromDate: formattedDate]; NSLog (@ "CalSHHMM:% @", CalSHHM); CalSHHMM Return; }  

There is no indication on why this is not working, and just tap back will be more than welcome.

appears to be the setting of your area, is not "N-US", so the date format supplied The string has not been parsed using the made N-US format. Although there may be a more elegant, simpler solution, using the sitelocking on en_US on the original dateformat can be used as a workaround for solving the problem.

As you've already tried in your code:

  [originalDateFormatter setLocale: [[NSLocale alloc] initWithLocaleIdentifier: @ "en_US"] autorelease]];  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -