shyamkumar bopannachengalaiah wrote: I am developing registration application where i have to store the creation date of the enduser in database. here the creation date should be server date. How can i write the code in my servlet to get the serverdate and insert into the mysql database?
Is there any specific need for this particular approach? i.e. taking Servlet host's time as the user creation time.
Are the application server and DB server in different timezones? Is there substantial network lag between the application and database servers? Are the user creation SQL statements executed as a batch?
If none of the above cases apply, then simply use the database's now() or similar function as the user creation time i.e. the time when the table row was inserted is taken as the user creation time.
In most cases the user creation date need not be anything beyond something like 08-Apr-2009, 17:09:03. But your requirement might require finer detail?
[edit]
BTW, if you choose to follow the parent's advise, take a look at both java.util.Date/Time and java.sql.Date/Time/Timestamp
regards
/k