String转换成Date 或Datetime
来源:互联网 发布:Linux tail查找 编辑:程序博客网 时间:2024/05/17 02:00
String time = "Tue Oct 30 2012 09:35:09 GMT+0800";
Date date = new Date(d);
SimpleDateFormat dateformat1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
time=dateformat1.format(date);
System.out.println(time);
try {
Date s1=dateformat1.parse(time);
System.out.println(s1+"-----------------");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我自己测试过了, 我是菜鸟,懂得不多,但是我用我仅限知道的代码写出了这个方法,可能会笨一点,但是的确可以从String转换成Datetime 希望大家支持!
Date date = new Date(d);
SimpleDateFormat dateformat1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
time=dateformat1.format(date);
System.out.println(time);
try {
Date s1=dateformat1.parse(time);
System.out.println(s1+"-----------------");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我自己测试过了, 我是菜鸟,懂得不多,但是我用我仅限知道的代码写出了这个方法,可能会笨一点,但是的确可以从String转换成Datetime 希望大家支持!
0 0
- String转换成Date 或Datetime
- 用js将long型数据转换成date型或datetime型
- 用JavaScript将long型数据转换成date型或datetime型
- python中date、datetime、string的相互转换
- python中date、datetime、string的相互转换
- python中date、datetime、string的相互转换
- Date转换成String
- Java中Date转换为Datetime、String与Date的相互转换
- simpledateformat String转换成 date;date转换成String
- String转换成date类型
- java String转换成Date
- String类型转换成date
- string 类型转换成DateTime时间格式
- DateTime类型转换成String类型截取
- java Date 转换 mysql datetime
- java的Date类型转换成MySQL的DateTime类型
- json中string类型的datetime格式转换为datetime类型:例string类型"/Date(1242357713797+0800)/" 转为datetime类型"yyyy-MM-dd"
- json中string类型的datetime格式转换为datetime类型:例string类型"/Date(1242357713797+0800)/" 转为datetime类型"yyyy-MM-dd"
- load-on-startup
- 打开struts-config.xml 报错 解决办法Could not open the editor
- CSS 盒子模型
- 使用 GNU Libtool 创建库
- 用Supervisord管理进程
- String转换成Date 或Datetime
- e.Item.ItemType 的用法
- android打不死的小强——永不磨灭的Servicr
- linux IPC之POSIX消息队列
- 区域生长法图像分割的实现方法
- cocos2d之网络特效CCGridAction && 场景切换特效CCTransitionCrossFade
- C#和java和android中的NetWorkAdapter,httpRequest,WebView,json,xml
- userInteractionEnabled交互性
- 多线程的基本概念及实现方式