如何在java中将日期转换为时间戳?
这一行给我以下错误: “构造函数 Timpestamp(Date) 未定义”
Timestamp timestamp = new Timestamp(Date);
最佳答案
试试这个:
import java.util.Date;
import java.sql.Timestamp;
public Timestamp convertDateToTimestamp(Date date) {
Timestamp timestamp = null;
if (date != null) {
timestamp = new Timestamp(date.getTime());
}
return timestamp;
}
关于java - 将日期转换为时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23549255/