如何在Java中将Date转换为Timestamp?
此行给我以下错误:“构造函数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;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句