我有一个String日期。这个日期是西方日期格式。我想要的是日文格式。
String a = "2019-05-10";
DateTimeFormatter timeFormatter = new DateTimeFormatterBuilder()
.appendPattern("YYYY-MM-DD")
.toFormatter(Locale.JAPAN);
String aa = LocalTime.parse(a, timeFormatter)
.format(DateTimeFormatter.ofPattern("YYYY年MM月DD日", Locale.JAPAN));
System.out.println(aa);
当前错误:
Exception in thread "main" java.time.format.DateTimeParseException: Text '2019-05-10' could not be parsed: Unable to obtain LocalTime from TemporalAccessor: {DayOfYear=10, MonthOfYear=5, WeekBasedYear[WeekFields[SUNDAY,1]]=2019},ISO of type java.time.format.Parsed
at java.time.format.DateTimeFormatter.createError(Unknown Source)
at java.time.format.DateTimeFormatter.parse(Unknown Source)
at java.time.LocalTime.parse(Unknown Source)
at testing.DatumTypeDecimal.main(DatumTypeDecimal.java:223)
Caused by: java.time.DateTimeException: Unable to obtain LocalTime from TemporalAccessor: {DayOfYear=10, MonthOfYear=5, WeekBasedYear[WeekFields[SUNDAY,1]]=2019},ISO of type java.time.format.Parsed
at java.time.LocalTime.from(Unknown Source)
at java.time.format.Parsed.query(Unknown Source)
... 3 more
预期输出:
2019年05月10日
隔江千里
墨色风雨
慕标5832272
吃鸡游戏
相关分类