• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with getting local time in servlet

 
kwame Iwegbue
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whenever i call new java.util.Date() or System.getCurrentTimeMillis(), the local time is returned on my development machine(which is in EST), but on actual web site i'm getting time from web server's location( which is in PST).

someone please help.
 
Zip Ped
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is because when you are using your development server, the development server is on your local machine and the time that is displayed is the system time of the local machine(i am assuming you have a server on you local machine for development)

When you deploy it on the server where your website is hosted, the system time displayed depends on the system time of the machine/server your application is deployed in.
 
kwame Iwegbue
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Kailash,

but i was wondering how to correct this behaviour?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's to correct? The code is running on the server, so it will always return the server time. It's behaving perfectly correctly.

If you want the time on the client, you'll have to have the client send it to you as a form submittal just like any other client-side data.
[ March 07, 2006: Message edited by: Bear Bibeault ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!