Swift将NSDate转换为24h格式在Device上失败

Mat*_*zio 0 nsdate nsdateformatter ios swift

当我在iPhone6上运行我的应用程序时,我遇到了一个恼人的错误.
我需要将一小时(由datePicker选取)从12h转换为24h格式.
简单的事!是的,我很确定,但是...我的代码在模拟器上工作,但在设备上没有.
代码如下:

func convertTimeTo24HoursFomratString() -> String {
        let dateFormatter = NSDateFormatter()
        // isFormatTime24Hours is a static function that returns me if the device has a 24h clock or not. It works fine both on device and on simulator
        //if NSDateUtility.isFormatTime24Hours() {
        //    dateFormatter.dateFormat = "h:mm a"
        //    return dateFormatter.stringFromDate(self)
        //}

        dateFormatter.dateFormat = "HH:mm"
        return dateFormatter.stringFromDate(self)
}
Run Code Online (Sandbox Code Playgroud)

我哪里做错了?
iOS版本到处都是9.1.
提前感谢您的回答!

[在Paul.s问题之后编辑]
在模拟器上它返回24h格式化日期(右).
在设备上它返回12h格式化日期(错误).

Tom*_*mmy 9

QA1480:将自己设置为格式化程序的语言环境en_US_POSIX.否则,设备的区域设置将影响日期模式.