当前位置: 首页 > 面试题库 >

如何从java.sql.Timestamp转换为java.util.Date?

连坚白
2023-03-14
问题内容

此代码

startDate = new Date(timestampValue.getTime));

给我 :

2012-16-02 05:16:17

什么时候

System.out.println(timestampValue);

返回:

2012-01-02 05:16:17.0


问题答案:

您应该改用日历:

Calendar start = Calendar.getInstance();
start.setTimeInMillis( timeStampValue.getTime() );


 类似资料: