Getting “unixtime” in Java

Date.getTime() returns milliseconds since Jan 1, 1970. Unixtime is seconds since Jan 1, 1970. I don’t usually code in java, but I’m working on some bug fixes. I have: Date now = new Date(); Long longTime = new Long(now.getTime()/1000); return longTime.intValue(); Is there a better way to get unixtime in java? 3 Answers 3

Converting unix timestamp string to readable date

I have a string representing a unix timestamp (i.e. “1284101485”) in Python, and I’d like to convert it to a readable date. When I use time.strftime, I get a TypeError: >>>import time >>>print time.strftime(“%B %d %Y”, “1284101485”) Traceback (most recent call last): File “<stdin>”, line 1, in <module> TypeError: argument must be 9-item sequence, not … Read more