Can you give me the proper difference between java.util.Date vs java.sql.Date ?

0 votes
I have a doubt regarding java.util.Date vs java.sql.Date these two dates.

Can you explain me the proper difference between them?
Aug 1 in Java by Sucheta

1 answer to this question.

0 votes
  1. As per Javadoc java.sql.Date is a thin wrapper around millisecond value which is used by JDBC to identify an SQL DATE type.

  2. java.sql.Date just represent DATE without time information while java.util.Date represents both Date and Time information. This is the major difference why java.util.Date can not directly map to java.sql.Date.

  3.  To suppress time information and to confirm with the definition of ANSI SQL DATE type, the millisecond values used in java.sql.Date instance must be "normalized by setting the hours, minutes, seconds and milliseconds to zero in the time-zone with DATE instance is associated. In other words, all time-related information is removed from java.sql.Date class.

Thank you, 

I hope this will help you to understand the difference.

answered Aug 2 by Sampriti
• 1,100 points

Related Questions In Java

0 votes
1 answer

How to calculate the difference between two date instances in Java?

You can use Joda Time Library. Interval i ...READ MORE

answered May 4, 2018 in Java by parth295
• 4,600 points
+1 vote
1 answer

Can you please explain the difference between string, string buffer and string builder?

String are immutable where as StringBuffer and ...READ MORE

answered Jul 4 in Java by Akash
• 160 points
0 votes
1 answer

Can you explain what is the difference between hashtable and hashmap?

Hi, Hashtable is synchronized, whereas HashMap is not. This makes HashMap better for ...READ MORE

answered 2 days ago in Java by anonymous
0 votes
1 answer

I am learning looping statements. Can you tell me how 'for-each' works in Java?

While programming we often write code that ...READ MORE

answered Apr 17, 2018 in Java by Rishabh
• 3,540 points
0 votes
1 answer

How can we convert java.util.Date to in Java?

Use java.time classes instead of java.util.Date & java.sql.Date with JDBC 4.2 or ...READ MORE

answered Jun 29, 2018 in Java by Sushmita
• 6,850 points
0 votes
1 answer

How can I convert a String variable to a primitive int in Java

You can convert a String to int by using a function: int ...READ MORE

answered Apr 12, 2018 in Java by sharth
• 3,320 points
0 votes
2 answers

Integer to String conversion in java

We can do this in 2 ways: String ...READ MORE

answered Jul 27, 2018 in Java by samarth295
• 2,190 points
0 votes
3 answers

String to Double conversion in java

Double temp = Double.valueOf(str); number = temp.doubleValue(); READ MORE

answered Sep 10, 2018 in Java by Sushmita
• 6,850 points
0 votes
1 answer

What is the difference between Map and HashMap in java?

Hi Sanhati, I understand your doubt regarding map ...READ MORE

answered May 31 in Java by Sampriti
• 1,100 points
0 votes
1 answer

Please explain me the difference between scanner and the buffer reader?

BufferedReader is synchronous while Scanner is not.  BufferedReader ...READ MORE

answered Aug 2 in Java by Sampriti
• 1,100 points