95% of all code makes me cry. The other 5% are white space.
// not really a date, but a Date Date date1 = new Date(0L); // really a date, but not a Date java.sql.Date sqlDate = java.sql.Date.valueOf("1970-01-01"); // really a date, but a Date? Date date2 = sqlDate; // a Date with time date1.getHours(); // a Date without time. <-- throws an IllegalArgumentException. // Wait, exactly *which* argument is illegal? date2.getHours();
Not following subtype contracts, about every type/method/exception name is a misnomer, java.util.Date was already broken, but java.sql.Date just makes it far worse.comments powered by Disqus
Send us your own example of code that made you cry! Please include:
Note that we may choose not to publish some submissions if we feel they're not appropriate. We hope you understand.
Use jOOQ, instead of JDBC.
jOOQ generates Java code from your database and lets you build typesafe SQL queries through its fluent API.