使用新的 DateTimeFormatter 直接解析YearMonth并设置其格式,并使用Locale设置所需的语言环境。
不要使用SimpleDateFormat。 那是旧的Date API的一部分。
尝试运行代码,看看这是否是您在Codiva在线编译器IDE中想要的。
YearMonth yearMonth = YearMonth.of(2016, 7);DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy MMMM", new Locale("it", "IT"));System.out.println(yearMonth.format(formatter));完整的工作代码在Codiva中。



