gpt4 book ai didi

java - 如何将 Rome 日期格式 "Sun Jan 08 02:25:00 IST 2012"日期转换为sql日期

转载 作者:行者123 更新时间:2023-11-29 03:50:38 25 4
gpt4 key购买 nike

我正在使用 rome 0.9 获取 rss 提要。但是从那个获取博客帖子的日期
如格式“Sun Jan 08 02:25:00 IST 2012”。

我无法将此日期格式转换为 sql 日期格式。实际上我想根据发布日期对博客文章进行排序。

如何解析日期。

最佳答案

试试这个方法,

String str_date  = "Sun Jan 08 02:25:00 IST 2012";
SimpleDateFormat fmt = new SimpleDateFormat("E MMM dd hh:mm:ss Z yyyy");
Date today = null;
try {
today = (Date)fmt.parse(str_date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

java.sql.Date dt = new java.sql.Date(today.getTime());
System.out.println(dt.toString());

关于java - 如何将 Rome 日期格式 "Sun Jan 08 02:25:00 IST 2012"日期转换为sql日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8967696/

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