【发布时间】:2022-06-10 16:38:12
【问题描述】:
我想在 kotlin 中将 MMYYYY 字段解析为 YearMonth。
试过的例子:
import java.time.YearMonth
import java.time.format.DateTimeFormatter
import java.time.format.DateTimeFormatterBuilder
val formatter: DateTimeFormatter = DateTimeFormatterBuilder()
.parseCaseInsensitive()
.appendPattern("MMYYYY")
.toFormatter(Locale.ENGLISH)
println(YearMonth.parse("011970", formatter))
没用
【问题讨论】: