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?
2 Answers
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);
3 Comments
newbie
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
Now I got it workign, first convert to long and then multiply with 1000
newbie
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