newbie
newbie

Reputation: 24635

PHP Integer base timestamp importing to Java Long base timestamp

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?

Upvotes: 1

Views: 1590

Answers (2)

Luca C.
Luca C.

Reputation: 12574

To avoid overflow:

Date d=new Date(((long)phpTimeStamp)*1000);

Upvotes: 0

yu_sha
yu_sha

Reputation: 4410

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);

Upvotes: 1

Related Questions