import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class TimeFormat {
public static void main(String[] args) {
Date date = null;
String str = null;
// 1 Date==>>String
date = new Date();
System.out.println(date);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
str = sdf.format(date);
System.out.println(str);
// 2 String==>>Date
str = "2012-9-12";
try {
date = sdf.parse(str);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(date);
date = new Date();
System.out.println(date.getTime());
Timestamp tp = new Timestamp(date.getTime());
System.out.println(tp);
System.out.println(Timestamp.valueOf("2012-12-12 12:12:12"));
}
}
分享到:
相关推荐
c#日期格式转换c#日期格式转换c#日期格式转换c#日期格式转换c#日期格式转换c#日期格式转换
Sql日期时间格式转换 大全 能用到的基本上都有了
长短日期格式转换.rar长短日期格式转换.rar长短日期格式转换.rar
java list<bean> date.class如果日期类型就改成这个 日期时间格式转换
sql server日期格式转换方法大全
JSON转换为JAVA对象及日期格式转换处理 -
sql 时间格式 转换大全,方便初学者使用时查看,作为工具使用!
net,日期,格式,转换 net,日期,格式,转换 net,日期,格式,转换 net,日期,格式,转换 net,日期,格式,转换 net,日期,格式,转换 net,日期,格式,转换 net,日期,格式,转换 net,日期,格式,转换
flex4 dataGrid 日期格式转换,flex4 dataGrid 日期格式转换.doc
java日期格式转换,让你玩转java日期和时间,快来下载吧!
Java日期格式转换.doc
易语言时间格式转换器.rar 易语言时间格式转换器.rar 易语言时间格式转换器.rar 易语言时间格式转换器.rar 易语言时间格式转换器.rar 易语言时间格式转换器.rar
易语言源码易语言脚本时间格式转换源码.rar 易语言源码易语言脚本时间格式转换源码.rar 易语言源码易语言脚本时间格式转换源码.rar 易语言源码易语言脚本时间格式转换源码.rar 易语言源码易语言脚本时间格式转换...
Sql Server日期格式转换是我们在使用Sql Server数据库时经常用到的操作,下面就将为您举一个Sql Server日期格式转换的例子,供您参考,希望对您学习Sql Server日期格式转换有所帮助。
Java时间格式转换大全
之前在做app,ios程序员要求将html5的日期(2015年10月15日转换为2015-10-15),这里了用户的错觉来实现,简单粗暴
SQL日期格式转换,把字段替换 GETDATE()就可。 适合于各种效果。
时间格式转换,提供丰富的时间格式转换方法
时间格式转换时间格式转换时间格式转换时间格式转换时间格式转换时间格式转换时间格式转换时间格式转换时间格式转换