mysql中对dateTime和timeStamp时间类型的获取
2013-04-07 14:24
501 查看
1、对dateTime时间类型的获取
数据库中时间为2013-4-9 10:14:29,使用String regTimeTemp = rs.getString("regTime");获取时间的结果是2013-4-9 10:14:29.0,最后一个表示毫秒数,需要截取字符串
public static String stringToString(String date){
String str = null;
if(date !=null){
str = date.substring(0,19);
}
return str;
}
2、对timeStamp时间类型的获取
先使用rs.getTimestamp("insertTime")获取时间,在使用SimpleDateFormat对他进行格式化就可以了
数据库中时间为2013-4-9 10:14:29,使用String regTimeTemp = rs.getString("regTime");获取时间的结果是2013-4-9 10:14:29.0,最后一个表示毫秒数,需要截取字符串
public static String stringToString(String date){
String str = null;
if(date !=null){
str = date.substring(0,19);
}
return str;
}
2、对timeStamp时间类型的获取
先使用rs.getTimestamp("insertTime")获取时间,在使用SimpleDateFormat对他进行格式化就可以了
相关文章推荐
- MySql中的时间类型datetime,timestamp,date,year比较
- 解决mysql datetime 类型设置默认值的方法,即mysql TIMESTAMP(时间戳)详解
- 关于mysql时间类型datetime与timestamp范围
- mysql所支持的日期时间类型有:DATETIME、 TIMESTAMP、DATE、TIME、YEAR。
- Mysql时间存储类型优缺点?DATETIME?TIMESTAMP?INT?
- 【翻译】【MySQL】Mysql数据库中时间类型说明(Mybatis,Date,DateTime,Timestamp);
- 关于mysql时间类型datetime与timestamp范围
- Mysql 时间类型 DATETIME、DATE和TIMESTAMP类型
- MySQL里面的时间类型datetime,date,timestamp,time和year(转)
- MySQL时间类型数据存储datetime、timestamp、int
- MYSQL时间类型datetime和timestamp的区别
- 关于mysql时间类型datetime与timestamp范围
- mysql 时间类型 datetime,timestamp
- Mysql时间存储类型优缺点?DATETIME?TIMESTAMP?INT?
- mysql建表一个timestamp类型字段会默认为当前时间,TIMESTAMP与DATETIME区别
- Mysql日期时间类型(DATE,DATETIME,TIMESTAMP)和函数及与linux系统时间之间的转换(UNIX_TIMESTAMP、FROM_UNIXTIME)
- 关于mysql时间类型datetime与timestamp范围
- mysql中的时间类型datetime,date,time,year,timestamp小知识点
- mysql 时间类型 timestamp和datetime
- 关于mysql时间类型datetime与timestamp范围