You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法解析时间字符串为LocalDateTime的问题求助

无法解析时间字符串为LocalDateTime的问题求助

各位大佬好,我最近碰到个头疼的问题:我想把字符串01:43:56转换成LocalDateTime对象,但每次尝试都会抛出错误,具体报错信息如下:

Text '01:43:56' could not be parsed: Unable to obtain LocalDateTime
from TemporalAccessor: {},ISO resolved to 01:43:56 of type
java.time.format.Parsed

我已经试过各种能想到的时间格式写法,可都没解决问题,比如:

  • LocalDateTime.parse("01:43:56", DateTimeFormatter.ofPattern("hh:mm:ss"))
  • LocalDateTime.parse("01:43:56", DateTimeFormatter.ofPattern("HH:mm:ss"))
  • LocalDateTime.parse("01:43:56", DateTimeFormatter.ofPattern("H:mm:ss"))
  • LocalDateTime.parse("01:43:56", DateTimeFormatter.ofPattern("H:m:s"))
  • LocalDateTime.parse("01:43:56", DateTimeFormatter.ISO_LOCAL_TIME)

实在摸不着头脑,有没有人能帮我看看问题出在哪呀?

备注:内容来源于stack exchange,提问作者Kris B

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 08:53:11