2012-01-18 12 views
0

配列から文字列形式で格納されている配列から日付を取得した日付はほとんどありませんが、今度は再び日付時刻をOOに変更します:OO:OO time..Myコードのない日私は正しい道をdoinのAMまたは私は何かが足りないのですかどうかなどNSDateを特定の時間に設定する

for(int i = 0 ; i<[keys count]; i++) 
{  
       NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 
       dateFormatter.timeStyle = NSDateFormatterNoStyle; 

       dateFormatter.dateFormat = @"dd-MMM-yyyy";  


      NSDate *noteDate = [dateFormatter dateFromString:[keys objectAtIndex:i]]; 

      NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; 
      NSDateComponents *weekdayComponents = [gregorian components:(NSDayCalendarUnit | NSWeekdayCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit)fromDate:[NSDate date]]; 

      NSInteger year = [weekdayComponents year]; 
      //NSInteger month = [weekdayComponents month]; 


      [gregorian setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; 
      NSDateComponents *timeZoneComps=[[NSDateComponents alloc] init]; 

      [timeZoneComps setYear:year]; 
      [timeZoneComps setHour:00]; 
      [timeZoneComps setMinute:00]; 
      [timeZoneComps setSecond:01]; 

      NSDate *noteDate1 =[gregorian dateFromComponents:timeZoneComps];   

      [self saveNotes:0 :noteDate1 :notes]; 
      NSLog(@"dates:%@",noteDate); 
     } 

を下回っている、友人は、私を助けてください..

よろしく ランジット

答えて

1

日付形式を

に設定してください
dateFormatter.dateFormat = @"dd-MMM-yyyy HH:mm:ss"; 

もこのライン

dateFormatter.timeStyle = NSDateFormatterNoStyle; 

をコメントアウトして、再度

を試してみてください
関連する問題