I get Integer timestamp from PHP program, but in Java timestamps are ing Long format. So how can I convert this PHP Integer timestamp to Java Long format and convert that long format to Date object?
+1
A:
PHP timestamp is number of seconds since 1/1/1970, and Java timestamp is number of milliseconds since 1/1/1970. So all you need to do in Java is multiply it by 1000.
Date d=new Date((long)phpTimeStamp*1000);
yu_sha
2009-11-16 11:32:07
Problem is that when I multiply Integer by 1000, it will overflow, so Is it possible to convert first to long and then multiply wiht 1000?
newbie
2009-11-16 11:37:52
Now I got it workign, first convert to long and then multiply with 1000
newbie
2009-11-16 11:40:01
Yes, that's why my code says (long)phpTimeStamp
yu_sha
2009-11-16 12:56:31
but now it multiplies Integer value by 1000 and after that it converts it to long, it should convert it first to long and then multiply. Like this => ((long)phpTimeStamp)*1000
newbie
2009-11-18 06:51:39