java中的date插入到mysql的datetime中的方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package com.hundsun;
import java.sql.Timestamp;
import java.util.Date;
/**
* Created by zeewane on 2016/7/29/0029.
*/
public class DateDemo {
public static void main(String[] args) {
Date date = new Date();
Timestamp timestamp = new Timestamp(date.getTime());
System.out.println(timestamp);//2016-07-29 16:28:44.526
}
}