에 내가이 nil
문자열을 다시 얻고있다 : 내 출력을 로그인 할 때이 형식의 날짜 문자열로 변환 : "2017년 1월 3일 16 : 50 : 00.0"나는 다음 사용할 때있는 NSDate
NSString *formatString = @"yyyy-MM-dd HH:mm:SS.Z";
NSString *dateString = @"2017-01-03 16:50:00.0";
NSDateFormatter *newDateFormatter = [[NSDateFormatter alloc] init];
[newDateFormatter setDateFormat:formatString];
[newDateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
[newDateFormatter setLocale:[NSLocale autoupdatingCurrentLocale]];
NSDate *newDate = [newDateFormatter dateFromString: dateString];
, 나는 무응답 날짜가 newDateFormatter
이지만, nil
newDate
입니다. 내가 도대체 뭘 잘못하고있는 겁니까?
행운을 빕니다 :) – Hackerman
당신이 DateFormat에 함께 stucked하는 경우 : 당신이 찾을 때까지 그것을 잘라하는 형식의 일부가 잘못되었습니다. 예를 들어,''yyyy-MM-dd HH : mm : SS' &''2017-01-03 16 : 50 : 00' 작업 (''ss','00'을'33'으로 바꾸면,) "Z"부분입니다. iOS의 DateFormat 문서는 다음 위치에 있습니다. http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns You ''0 '을''Z' '로 timeZone으로 변환 할 수 없다는 것을 알 수 있습니다. 무엇을 표현할 지 모르겠지만 그것을 발견 할 필요가 있습니다. 내 추측 : =>'yyyy-MM- dd HH : mm : ss.SSS' – Larme