gpt4 book ai didi

java - 将 date.toString() 转换为日期

转载 作者:行者123 更新时间:2023-11-30 10:51:40 24 4
gpt4 key购买 nike

我正在尝试将字符串转换为日期。我这里有一个示例,其中输入字符串是硬编码字符串。

try {
String currentDate = "Tue Jan 05 21:19:57 CET 2016";
Date d = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US).parse(currentDate);
} catch (ParseException e) {
e.printStackTrace();
}

出于某种原因,这会引发以下异常:

ParseException: Unparseable date: "Tue Jan 05 21:19:57 CET 2016" (at offset 20)

有人可以帮我解决这个问题吗?谢谢!

最佳答案

她描述了你的问题java.text.ParseException: Unparseable date

你的机器本地可以影响SimpleDateFormat中使用的本地

关于java - 将 date.toString() 转换为日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34622097/

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