如何从java.sql.Timestamp转换为java.util.Date?
即此代码
startDate = new Date(timestampValue.getTime));
给我 :
2012-16-02 05:16:17
什么时候
System.out.println(timestampValue);
返回:
2012-01-02 05:16:17.0
即此代码
startDate = new Date(timestampValue.getTime));
给我 :
2012-16-02 05:16:17
什么时候
System.out.println(timestampValue);
返回:
2012-01-02 05:16:17.0
类从 扩展自 。java.sql.TimeStamp
java.util.Date
您可以直接指定要引用的对象:TimeStamp
Date
TimeStamp timeStamp = //whatever value you have;
Date startDate = timestampValue;
您应该改用日历:
Calendar start = Calendar.getInstance();
start.setTimeInMillis( timeStampValue.getTime() );