Difference Betwixt Java.Util.Date Together With Java.Sql.Date Inward Coffee - Jdbc Interview Question
Difference betwixt java.util.Date in addition to java.sql.Date inwards Java or why does Java has java.sql.Date if at that spot is already a Date flat inwards coffee util bundle is a common coffee interview question. There is e'er confusion alongside many Java developer familiar with both java.util.Date in addition to java.sql.Date. Though many of them already using java.sql.Date to interface with DATE type of whatever relational database similar mysql, oracle or whatever other database. In this Java tutorial nosotros volition encounter some differences betwixt java.sql.Date in addition to java.util.Date which volition assistance to empathise both of them better.
This Java tutorial is inwards continuation of our before postal service on java.util.Date similar How to convert String to Date inwards Java in addition to how to larn electrical flow Date in addition to Time value inwards GMT timezone. if y'all haven't read them already y'all may honour them interesting in addition to useful. If y'all similar JDBC articles in addition to then checkout some JDBC Performance tips and Benefits of PreparedStatement inwards Java.
Difference betwixt java.util.Date in addition to java.sql.Date inwards Java
Here are few differences on java.sql.Date in addition to java.util.Date inwards Java inwards betoken format, if y'all whatever other divergence betwixt them which is worth noting in addition to then delight postal service inwards comments :
1. As per Javadoc java.sql.Date is a sparse wrapper closed to millisecond value which is used past times JDBC to position an SQL DATE type.
2. java.sql.Date merely represent DATE without fourth dimension information spell java.util.Date correspond both Date in addition to Time information. This is the major differences why java.util.Date tin non straight map to java.sql.Date.
3. In gild to suppress fourth dimension information in addition to to confirm with Definition of ANSI SQL DATE type, the millisecond values used inwards java.sql.Date representative must last "normalized past times setting the hours, minutes, seconds in addition to milliseconds to naught inwards the timezone with with DATE representative is associated. In other words all fourth dimension related information is removed from java.sql.Date class.
>
Why create y'all bespeak java.sql.Date if at that spot is already java.util.Date exits ?
By the agency if y'all larn this JDBC interview query correct at that spot are to a greater extent than interesting questions to comes every bit follow-up similar :
What is divergence betwixt java.sql.Date, java.sql.Time in addition to java.sql.Timestamp ?
How to convert java.sql.Date into java.util.Date in addition to vice versa ?
Better to laid for these questions also , I volition try to postal service answers of these JDBC questions inwards another post.
That's all on difference betwixt java.sql.Date in addition to java.util.Date. In summary sql engagement correspond entirely Date information (e.g. year, month, day) spell util Date correspond both engagement in addition to fourth dimension information. Other Java questions y'all may like
Further Learning
JSP, Servlets in addition to JDBC for Beginners: Build a Database App
Complete JDBC Programming Part 1 in addition to 2
Why Java doesn’t back upwards multiple inheritance
Komentar
Posting Komentar