Service for getting Current time gives wrong output on your server

0 votes

I have made one service which simply gives me a current time , service gives me perfect time in my eclipse but when i deploy and run it on your server it shows me wrong time..

I have used below line for current time

 String timeStamp = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(Calendar.getInstance().getTime());

asked Aug 9, 2016 in Android by testdemo772 (47 points)

1 Answer

0 votes

Hi TestDemo,


If you are using Calendar API without setting the TimeZone, it will give the time as per location of the server is running.

So in this case as your location is different from server location it will give you two different time as per their TimeZone.

So I suggest you to set a TimeZone in that it will give you same time whatever the location is. Adding on this if you fetch time in miliSec using Calendar.getInstance().getTime().getTime() it will always be same whatever the location is.

Let me know if it helps.


Vishnu Garg


answered Aug 9, 2016 by Vishnu Garg (674 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on