Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between sql.Date and util.Date  RSS feed

 
rama murthy
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between sql.Date and util.Date

Please don't tell sql date is a sub-class of util.Date
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.sql.Date exists to wrap the ANSI SQL DATE datatype. See the JavaDocs for more.
 
rama murthy
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could you please throw more light on this topic.
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.sql.Date dosen't store millisecond information while java.util.Date does.
[ February 15, 2007: Message edited by: Srinivasa Raghavan ]
 
rama murthy
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks srini.

But even sql.Date is having a constructor that takes milli seconds right?

I didn't fully understand your answer.
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From javadoc link in one of the responses:


A thin wrapper around a millisecond value that allows JDBC to identify this as an SQL DATE value. A milliseconds value represents the number of milliseconds that have passed since January 1, 1970 00:00:00.000 GMT.

To conform with the definition of SQL DATE, the millisecond values wrapped by a java.sql.Date instance must be 'normalized' by setting the hours, minutes, seconds, and milliseconds to zero in the particular time zone with which the instance is associated.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!