Originally posted by Joel McNary: User java.sql.Timestamp instead of java.sql.Date. java.sql.Date does not carry time information (as per the SQL specification!); java.sql.Timestamp does.
It's an extremely important skill to learn to read the API and become familiar with the tools you will use to program Java. Java has an extensive set of documentation that you can even download for your convenience. These "javadocs" are indexed and categorized so you can quickly look up any class or method. Take the time to consult this resource whenever you have a question - you'll find they typically contain very detailed descriptions and possibly some code examples.
Actually, depending on the database you're using, you might consider setting up your table so that it uses a timestamp field, or so your date field otherwise has the current date/time as the default value.
Then you don't have to worry about the current date/time in your Java code. You simply insert the new record, either passing a "null", or just not giving it any data for that field. The database engine will automatically use the current date/time when it adds the record.
Although, again, whether you can do this, and how you would do it, all depends on your back-end database.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus