【发布时间】:2017-05-22 00:10:18
【问题描述】:
我试图弄清楚如何格式化已经使用 String.CharacterView 格式化的字符串。
代码是:
let formattedDate = arrivalTime.characters.suffix(8) //gets the last 8 characters of a JSON outputted string for the time
record.time = String(formattedDate) //sets the characters to a string and then sets that equal to the record class variable time, which displays the string in each table view cell
self.records.append(record)
这会产生类似
的字符串18:41:21
我想弄清楚的是如何获得像
这样的字符串6:41pm
而不是 18:41:21
有人有什么建议吗?谢谢!
【问题讨论】:
标签: ios json swift string swift3