来自服务器的initWithFormat值的问题

时间:2014-07-24 08:42:56

标签: objective-c nsdateformatter nscalendar

请如何让我的initWithFormat在上午8:00 - 下午2:30显示?

请帮助!!我已经在'添加了" dd-MM-yyyy' h:mm:ss a"

//opening
    NSString *startDate= ((Timeslot *)[self.timeslots objectAtIndex:i]).startDateTime;
    NSArray *split =[startDate componentsSeparatedByString: @"T"];
    NSString* clock =[split objectAtIndex: 1];
    NSArray *aux= [clock componentsSeparatedByString:@":"];
    NSString *startTime = [[NSString alloc] initWithFormat:@"%@:%@",[aux objectAtIndex:0],[aux objectAtIndex:1]];

    NSArray *st = [sttHour componentsSeparatedByString: @":"];
    if([[st objectAtIndex:0] integerValue] < [[aux objectAtIndex:0] integerValue])
    {
        if(![self.openings containsObject:startTime])
        {
            [self.openings addObject:startTime];
            [self.closings addObject:startTime];
        }

        [self.frees addObject:startTime];
    }

这是我从服务器获得的值:

Timeslot =  {
            endDateTime = "2014-07-25T16:00:00";
            id = 1344;
            startDateTime = "2014-07-25T14:00:00";
        };

1 个答案:

答案 0 :(得分:1)