http:blog.sina.com.cnsblog_4953e9290100c2tz.htmlhttp:www.cnblogs.comBearOceanarchive200704 http://blog.sina.com.cn/s/blog_4953e9290100c2tz.html http://www.cnblogs.com/BearOcean/archive/2007/04/09/705751.html java中格式化当前日期并转成
http://blog.sina.com.cn/s/blog_4953e9290100c2tz.html
http://www.cnblogs.com/BearOcean/archive/2007/04/09/705751.html
java中格式化当前日期并转成字符串
DateFormat formatter new
SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String datetime
formatter.format(new java.util.Date());
通过java向mysql中插入datetime
类型的数据
String sql "INSERT INTO wp_posts ( post_date )VALUES(?)";
PreparedStatement pstmt connection.prepareStatement(sql);
Timestamp time new Timestamp(System.currentTimeMillis());
pstmt.setTimestamp(1, time);
类似的有
pstmt.setDate(10, new java.sql.Date(System.currentTimeMillis()));
// 只有日期
pstmt.setTime(11, new
Time(System.currentTimeMillis()));
// 只有时间
pstmt.setTimestamp(12, new Timestamp(System.currentTimeMillis()));
// 日期和时间
分享到
2009-07-23 09:37
浏览 4689
评论