0

I'm experiencing a very strange problem with Date objects in Android, when I run the following code I get different dates in the emulator and in the real device. (str1 and str2 come from the following json result json file)

String str1="1450967458";
String str2="1450980000";
Date dstart=new Date((long)Long.parseLong(str1)*1000);
Date dend=new Date((long)Long.parseLong(str2)*1000);
     
Log.i("VILLANUEVA","START:"+dstart.toString());
Log.i("VILLANUEVA","END:"+dend.toString());

Dates in real device:

... I/VILLANUEVA: START:Thu Dec 24 15:30:58 CET 2015

... I/VILLANUEVA: END:Thu Dec 24 19:00:00 CET 2015

Dates in emulator(These are the correct dates)

...I/VILLANUEVA: START:Thu Dec 24 09:30:58 EST 2015

...I/VILLANUEVA: END:Thu Dec 24 13:00:00 EST 2015

It seems to be a difference of 6 hours between the device and the emulator. I've tested with Calendar class and I get the same difference. Any help would be appreciated. Thanks in advance.

Community
  • 1
  • 1
Carlos Hernández Gil
  • 1,853
  • 2
  • 22
  • 30

0 Answers0