xml parser, in iPhone - iphone

Am getting date (10/02/2011) in xmlresponse how to get this value in to string using NSXmlParserDelegate. "/" blocks me and am not getting how to handle this..
Thanks in advance..

Use NSDateFormatter to get date from NSString from any formats.

You have not been clear where this xml data is coming from, I couldnt turn anything up on how dates should be formatted in xml. The first thought is "you are doing it wrong" if you can try using a different separator for dates, parse them out of the stream before you give the data to NSXMLParser. I know which I would prefer.

Related

Parsing new Date in JSON

I am making a request for data and parsing it in JSON format however I do get errors because it returns timestamps in the javascript form new Date(1500000). How do I go about fixing this issue.
I thought of using regex to put quotes around the new Date(0000000) but it doesn't seem to work. I am using RegexKitLite and SBJSON. Thanks in advance for the help
You can simply use;
value = new Date(parseInt(value.replace("/Date(", "").replace(")/", ""), 10));
where value is your "Date(1500000)" string.

Comparing the Key before adding to NSDictionary

I am adding dates into dictionary as the key and the corresponding value as some text ,but I am converting the date into string ,before adding to a dictionary,I have written the below code
[dateNoteDict setValue:datestring forKey:notes.text];
but before adding to dictionary I want to make some date comparision such that ,if the date present in dictionary is greater than ,the nest date then ,I should add below in the dictionary and so..on..
But I am not understanding how to do that.
So friends,please help me out..
Regards
Ranjit
You should do the comparison before converting the dates into NSStrings.
Assuming you are using NSDate objects, you can use the compare method. Have a look at this answer from S.O about date comparison.
Set some particular date format while setting as key in your dictionary. You can use NSDateFormatter for this. Also convert new date in the same format and then use "compare" for date comparison.
Thanks

Convert Formate of internet time to Nsdate Format in Desire

2011-08-06T12:29:10.703+05:30
i have following date that i have convert in this format like
"2011-08-06T12:29:10+05:30"
Here is a nice blog to have a better idea...
A more better explain is on this link
You can see that you need more than one date NSDateFormater for this job

How to add characters to a NSString?

i have strings who look like this 20110525 .
how can i make to put '-' caracters in NSString variable ? to let dates look like this 2011-05-25 ?
My second question is how can i sort the dates to make the table look like this 20110525 then 20110526 ?Help please . Thank you
Why not just use the NSDate class to get the date, and use an NSDateFormatter to format the date the way you want.
you can try using sscanf(input,"%4d%2d%2s",&year,&month,&day) to parse input string and sprintf(output,"%d-%d-%d",year,month,day) to format your date.

sqlite writing a date into an email

I am exporting a date value from sqlite and placing it into an email. The date appears like this
279498721.322872
I am using Objective C in an Iphone App. Does anyone know how to make this export out as a regular date whether it is all number like
2009-02-10 or anything legible?
Well, if you take the number 279498721.322872 and throw it into an NSDate object using +dateWithTimeIntervalSinceReferenceDate, you get (here in the MDT timezone): 2009-11-09 15:32:01 -0700, which was just under 4 hours ago. If that's the time you're expecting, then formatting it is as simple as using an NSDateFormatter.
However, the thing to notice is that sqlite (by default) stores dates as textual representations (unless you specify differently in the sql statement). So the real question here is "where are you getting that number from?"
echo date("Y-m-d",time(279498721.322872));
Thanks for the responses. The answer came from my Guru Alex Cone. He told me to use the following:
NSTimeInterval tempInterval = (NSTimeInterval)sqlite3_column_double(statement, 4);
The tempInterval variable can then be loaded into the the NSDate method.