java.util.date的格式,在java中将字符串转换为java.util.date格式

这篇博客探讨了如何将格式为' Thu Oct 07 11:31:50 IST 2010'的日期字符串转换为Java的Date对象。通过使用SimpleDateFormat类并指定正确的日期格式('EEEMMMddHH:mm:ss z yyyy'),可以成功完成转换。这个问题对于处理日期和时间数据在SQL存储中非常重要。
摘要由CSDN通过智能技术生成

am having a string like this.

Thu Oct 07 11:31:50 IST 2010

I want to convert this into its exact date time format to store it in SQL.

Am familiar with so many string to date conversions like the following.

String dateString = "2001/03/09";

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/mm/dd");

Date convertedDate = dateFormat.parse(dateString);

But i need to convert a string like Thu Oct 07 11:31:50 IST 2010

into its Date format with timestamp.

Can anyone explain the proper way of converting this into its java.util.Date format.?

解决方案

Try this:

SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值