0

I am using following code to set SQL timestamp in calendar instance, it is working fine. Is this correct?

 TimeStamp expireDate= ab.getUExpireDate();
 Calendar cal = Calendar.getInstance(); 
 cal.setTime(expireDate); // ← this line

2 Answers2

1

You can check the difference in util.Date and sql.Date in the following post

java.util.Date vs java.sql.Date

Community
  • 1
  • 1
sumitsabhnani
  • 320
  • 1
  • 6
0

You can import:

1)java.sql.Timestamp

***The biggest difference between java.sql.Date and java.sql.Timestamp is that the java.sql.Date only keeps the date, not the time, of the date it represents. So, for instance, if you create a java.sql.Date using the date and time 2014-12-24 21:20, then the time (21:20) would be cut off. If you use a java.sql.Timestamp then the time is kept.

method to add timeStamp object in Calender is :

2) cal.setTime(expireDate);

Dawlatzai Ghousi
  • 3,780
  • 2
  • 20
  • 26