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

  • SEARCH
  • Home
  • 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 8324505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:05:52+00:00 2026-06-09T00:05:52+00:00

I am having the following string as input : BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT SUMMARY;CHARSET=utf-8:hello LOCATION;CHARSET=utf-8:loc

  • 0

I am having the following string as input :

BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
SUMMARY;CHARSET=utf-8:hello 
LOCATION;CHARSET=utf-8:loc 
DTSTART:20120704T053000Z
DTEND:20120704T073000Z
END:VEVENT
END:VCALENDAR

The problem I’m facing is with the date part I’m using :

    NSRange end = [Result rangeOfString:@"T"];

            NSString *DT=[NSString stringWithFormat:@"%@%@",[Result substringToIndex:end.location],[Result substringFromIndex:end.location+1]];

            NSDateFormatter *formatter=[[NSDateFormatter alloc] init];
            [formatter setTimeZone:[NSTimeZone defaultTimeZone]];
            [formatter setDateFormat:@"yyyyMMddHHmmssZ"];

            NSDate *dt=[formatter dateFromString:DT];   

            myEvent.startDate=dt;
            [formatter release];

dt returns here is NULL , what am I doing wrong?

Updated Code: I updated the code as follows , now am able to get date but needed to ask, do i need to set locale or timezone ??

        [NSTimeZone resetSystemTimeZone]; 
        NSLocale *enUSPOSIXLocale;
        NSDateFormatter *sRFC3339DateFormatter = [[NSDateFormatter alloc] init];     

        if( [Result characterAtIndex:[Result length]-2] == 'Z')
        {   
            NSLog(@"in 1");
            [sRFC3339DateFormatter setDateFormat:@"yyyyMMdd'T'HHmmss"];
         }
        else 
        {
            NSLog(@"in 2");
            [sRFC3339DateFormatter setDateFormat:@"yyyyMMdd'T'HHmmssZ"];
        }

        NSDate *date = [sRFC3339DateFormatter dateFromString:[Result substringToIndex:[Result length]-2]];

        myEvent.startDate=date;
  • 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-09T00:05:53+00:00Added an answer on June 9, 2026 at 12:05 am

    Look at your format:

    [formatter setDateFormat:@"yyyyMMddHHmmssZ"];
    

    Now look at an example string:

    20120704T073000Z
    

    You’re missing the T. I don’t know whether it needs escaping, so you might want either of these:

    [formatter setDateFormat:@"yyyyMMddTHHmmssZ"];
    [formatter setDateFormat:@"yyyyMMdd'T'HHmmssZ"];
    

    Note that the Z at the end means “UTC” – I don’t know whether iOS will automatically take that into account or not, but it at least means that setting the time zone to the default time zone is misleading. I’d set it to UTC or not at all.

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

Sidebar

Related Questions

I'm having some issues using the following code on user input: htmlentities($string, ENT_COMPAT, 'UTF-8');
I'm having trouble finding a regular expression that matches the following String. Korben;http://feeds.feedburner.com/KorbensBlog-UpgradeYourMind?format=xml;1 One
Having the following class (.Net 3.5): public class Something { public string Text {get;
Having the following classes, in two different assemblies: class Member { public string Label
I'm having a weird problem with the following function, which returns a string with
I'm having problem parsing the Date from an input string that is of the
Having the following hierarchical text data input (JunOS-like, in fact) I need to parse
I am using Hibernate 4.1 and Spring 3.1. Consider the following User class having
I have DB2 table having following structure CREATE TABLE DUMMY ( ID CHARACTER(10) NOT
I am having following class hierarchy - //Abstract Class1 in library1 (Can't modify this)

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.