gpt4 book ai didi

java - 解析异常 : Unparseable date in a custom method for parsing dates

转载 作者:行者123 更新时间:2023-12-01 17:46:08 27 4
gpt4 key购买 nike

我编写了一个解析日期的方法。当我将以下日期作为参数传递时 2019-03-05 06:15:00 ,我得到一个java.text.ParseException: Unparseable date: "2019-03-05 06:15:00"

逻辑可能有什么问题?

public String convertDate(String val) throws ParseException {
return "cast('" + new SimpleDateFormat("yyyy-MM-dd HH:mm:SS").format(
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'").parse(val)) + "' as ts)";
}

最佳答案

您正在尝试使用模式 yyyy-MM-dd'T'HH:mm'Z' 解析字符串 2019-03-05 06:15:00显然不适合。

关于java - 解析异常 : Unparseable date in a custom method for parsing dates,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55239984/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com