Difference Betwixt Java.Util.Date In Addition To Java.Sql.Date Inwards 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 parcel is a common coffee interview question. There is ever confusion amid many Java developer familiar alongside both java.util.Date in addition to java.sql.Date. Though many of them already using java.sql.Date to interface alongside DATE type of whatever relational database similar mysql, oracle or whatever other database. In this Java tutorial nosotros volition run across some differences betwixt java.sql.Date in addition to java.util.Date which volition assistance to sympathise 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 teach electrical flow Date in addition to Time value inwards GMT timezone. if you lot haven't read them already you lot may notice them interesting in addition to useful. If you lot 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 you lot 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 roughly millisecond value which is used yesteryear JDBC to position an SQL DATE type.
2. java.sql.Date simply 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 guild to suppress fourth dimension information in addition to to confirm alongside Definition of ANSI SQL DATE type, the millisecond values used inwards java.sql.Date event must survive "normalized yesteryear setting the hours, minutes, seconds in addition to milliseconds to zilch inwards the timezone alongside with DATE event is associated. In other words all fourth dimension related information is removed from java.sql.Date class.
>
Why create you lot necessitate java.sql.Date if at that spot is already java.util.Date exits ?
database is to a greater extent than unopen to java.util.Date, It extends java.util.DATE in addition to if you lot are using java.util.DATE inwards your Class to correspond DATE value its ameliorate to role TIMESTAMP type inwards Database in addition to java.sql.Time inwards JDBC or DAO code.
By the means if you lot teach this JDBC interview inquiry 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 too , 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 appointment correspond solely Date information (e.g. year, month, day) spell util Date correspond both appointment in addition to fourth dimension information. Other Java questions you lot 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 upwardly multiple inheritance
0 Response to "Difference Betwixt Java.Util.Date In Addition To Java.Sql.Date Inwards Coffee - Jdbc Interview Question"
Post a Comment