import java.util.Date; public class Timestamp { /** 获取精确到毫秒的时间戳 * @param date * @return **/ public static Long getTimestamp(Date date){ if (null == date) { return (long) 0; } String timestamp = String.valueOf(date.getTime()); return Long.valueOf(timestamp); } public static void main(String[] args) { Date d = new Date(); System.out.println(getTimestamp(d)); //结果:1504535566231 } }
原文:http://www.cnblogs.com/unknows/p/7476262.html