Reputation:
I have following code, running on Unix server (WAS 5.1), it's a test environment in our company. When I try to execute the below code, I always get yesterday's date (i.e if I execute today 9/27/2012 it returns date as 9/26/2012)
long userSelectedTimeLong = date.getTime()
Upvotes: 0
Views: 390
Reputation: 1883
Another possibility : does the server sync with some kind of time service ? (ntp, ...) Maybe it 's just the system date on the Unix machine that has been set wrong.
Upvotes: 0
Reputation: 1
It would be good use
long userSelectedTimeLong = Calendar.getInstance().getTimeInMillis()
Upvotes: 0
Reputation: 1883
I have had a similar problem once ;-) Check wether the local date variable is instantiated when the application launches and perhabs not being refreshed while the application runs.
Upvotes: 0
Reputation: 19185
Date returns time based on TimeZone
of the machine. It is possible that your sever might be hosted some where else and TimeZone value is different.
You need to compare value of date by having same TimeZone.
Once you do that next task is is date
variable really contains current date. You can print a simple log using new Date().getTime()
Upvotes: 1