Objective c NSDateFormatter将午夜显示为24而不是00

Objective c NSDateFormatter将午夜显示为24而不是00,objective-c,nsdate,nsdateformatter,Objective C,Nsdate,Nsdateformatter,在我的应用程序中,我使用NSDate和nsdateformatter以以下格式显示小时:HH:mm。当我传递表示午夜的时间戳时,例如:1603843200000 我希望时间是00:00,而不是24:00。我怎样才能把时间定为00:00 下面是我用来格式化时间戳的代码: NSNumber* timeStamp = currentConsumption.timestamp; // 1603843200000 NSDate* date = [NSDate dateWithTimeIntervalSin

在我的应用程序中,我使用
NSDate
nsdateformatter
以以下格式显示小时:
HH:mm
。当我传递表示午夜的时间戳时,例如:
1603843200000
我希望时间是00:00,而不是24:00。我怎样才能把时间定为00:00

下面是我用来格式化时间戳的代码:

NSNumber* timeStamp = currentConsumption.timestamp; // 1603843200000
NSDate* date = [NSDate dateWithTimeIntervalSince1970:([timeStamp longLongValue]/1000)];
NSDateFormatter* df = [NSDateFormatter new];
df.dateFormat = self->graphDateFormat; // @"k:mm"
if(self->graphType == day){
      [df setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
}
return  [df stringFromDate:date];

问题是,我将格式设置为
k:mm
,而不是
HH:mm

df的值。dateFormat
HH:mm
k:mm
?@Willeke,它是
k:mm
,一旦我将它更改为
HH:mm
,它就工作了。