1
NSDateComponents를 사용하여 NSDate 객체를 가져 오려고하지만 NSDate의 시간은 구성 요소에서 1 시간 낮습니다.NSDate 결과 from - (NSDate *) dateFromComponents : (NSDateComponents *) comps
NSCalendar *cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
[cal setLocale:[NSLocale currentLocale]];
[cal setTimeZone:[NSTimeZone localTimeZone]];
NSDateComponents *hourComp = [[NSDateComponents alloc] init];
hourComp.timeZone = [NSTimeZone localTimeZone];
[hourComp setHour:18];
NSLog(@"%@",hourComp);
NSLog(@"%@",[cal dateFromComponents:hourComp]);
NSLog(@"%@",[NSDate date]);
콘솔 출력 : 내가 원하는 무엇
2012-04-10 19:10:57.505 TestDate[9861:f803] <NSDateComponents: 0x6b6ad30>
TimeZone: Europe/Berlin (CEST) offset 7200 (Daylight)
Hour: 18
2012-04-10 19:10:57.507 TestDate[9861:f803] 0001-01-01 17:06:32 +0000
2012-04-10 19:10:57.508 TestDate[9861:f803] 2012-04-10 17:10:57 +0000
은 18 : XX : XX