java.time.format.DateTimeParseException:无法在索引0处解析文本'Tue Jan 08 00:00:00 IST 2019' [英] java.time.format.DateTimeParseException: Text 'Tue Jan 08 00:00:00 IST 2019' could not be parsed at index 0

查看:98
本文介绍了java.time.format.DateTimeParseException:无法在索引0处解析文本'Tue Jan 08 00:00:00 IST 2019'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使提供了适当的格式,我也面临着 DateTimeParseException

I am facing DateTimeParseException even after giving appropriate format

DateTimeFormatter ft = DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss z yyyy");
LocalDateTime.parse("Tue Jan 08 00:00:00 IST 2019", ft);

如果我有任何遗漏,请提供帮助?

Please help if I am missing anything?

推荐答案

这可能是由于计算机上的区域设置所致.创建DateTimeFormatter时,您可以提供语言环境.

This is probably due to the locale setting on your computer. You might provide a Locale when creating the DateTimeFormatter.

DateTimeFormatter ft = DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss z yyyy", Locale.US);

这将确保正确地解析日期.

This will ensure that the date is always parsed right.

这篇关于java.time.format.DateTimeParseException:无法在索引0处解析文本'Tue Jan 08 00:00:00 IST 2019'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆