Difference between Date class in Package java.util & Package java.sql

后端 未结 5 1058
太阳男子
太阳男子 2020-12-16 04:30

In java, both the java.util and the java.sql package contain a Date class, So what is the difference between them?

If one

5条回答
  •  囚心锁ツ
    2020-12-16 04:54

    java.sql.Date accepts a long integer which represents the amount of milliseconds since January 1, 1970. If the given number is negative it refers time before January 1, 1970. Remember, the encapsulated value inside the object represents only date like January 1, 1970 and no time information is stored.

    java.util.Date stores both date as well as time information. It is more commonly used than java.sql.Date.

提交回复
热议问题