pt-BR DateFormatter Swift错误行为

时间:2019-09-17 15:47:06

标签: ios swift nsdate dateformatter

我有此方法可以解析字符串Date:

  let dateFormatterGet = DateFormatter()
  let stringDate = "31/01/1965"
  dateFormatterGet.dateFormat = "dd-MM-yyyy"
  dateFormatterGet.locale = Locale(identifier: "pt_BR")
  let birthDate = dateFormatterGet.date(from: stringDate)
  print(birthDate)

如果Date是31/01/1965(January 31st),则birthDate返回nil,但是如果我将日期更改为30,则一切正常。怎么了?

0 个答案:

没有答案