java: long to Date/Time/Timestamp
java中,long转换成日期格式有下面三种情况
1、long to Date
System.out.println("java.sql.Date:" new java.sql.Date(l));
结果:java.sql.Date:1970-01-15
2、long toTime
System.out.println("java.sql.Time:" new java.sql.Time(l));
结果:java.sql.Time:14:46:40
3、long to Timestamp
System.out.println("java.sql.Timestamp:" new java.sql.Timestamp(l));
结果:java.sql.Timestamp:1970-01-15 14:46:40.234
Courtesy costs nothing. 彬彬有礼,惠而不费 。