Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 德语工作日,而不是英语工作日,Dateformatter_Ios_Iphone_Xcode_Date_Swift4.2 - Fatal编程技术网

Ios 德语工作日,而不是英语工作日,Dateformatter

Ios 德语工作日,而不是英语工作日,Dateformatter,ios,iphone,xcode,date,swift4.2,Ios,Iphone,Xcode,Date,Swift4.2,我怎样才能得到工作日的名字,但德语不是英语。我试过了,但我没法在德国工作日工作 func returnWeekDay() -> String? { let formatter = DateFormatter() formatter.dateFormat = "dd.MM.yyy" formatter.timeZone = TimeZone(identifier: "de_DE") guard let todayDate = formatter.date(fr

我怎样才能得到工作日的名字,但德语不是英语。我试过了,但我没法在德国工作日工作

func returnWeekDay() -> String? {
    let formatter = DateFormatter()
    formatter.dateFormat = "dd.MM.yyy"
    formatter.timeZone = TimeZone(identifier: "de_DE")
    guard let todayDate = formatter.date(from: returnFormattedDate()) else { return nil }

    let nameOfDay = formatter.weekdaySymbols[Calendar(identifier: .gregorian)
        .component(.weekday, from: todayDate)]
    return nameOfDay
}

要获取德语日期,请使用:


formatter.locale=locale(标识符:“de_de”)

尝试设置日期格式化程序的
locale
,而不是时区。