• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

server date

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 689
Scala Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

hi,

I think you can get date and time using

java.util.Date date = new java.util.Date();

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
shyamkumar bopannachengalaiah
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kalyan Ram wrote:

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




thankyou very much.
 
shyamkumar bopannachengalaiah
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nishan Patel wrote:
hi,

I think you can get date and time using

java.util.Date date = new java.util.Date();



thanks for your kind solution.
reply
    Bookmark Topic Watch Topic
  • New Topic