java Date 和 TimeStamp 互相转换

1. Date 转 TimeStamp

Date date = new Date();
Timestamp ts = new Timestamp(date.getTime());

2. TimeStamp 转 Date

Timestamp ts  = new Timestamp(System.currentTimeMillis());
Date date = new Date(ts.getTime());

 

posted @ 2022-12-13 21:37  小log  阅读(4006)  评论(0编辑  收藏  举报