一般的时间类型都是2013-5-31 19:40:00 或者 2013/5/31/ 19:40:00 这种形式,今天在爬取网页的时候,浏览器返回来的数据包中的时间是feedTime:1363355755000 这种一长串的数字,大家知道怎么把它转换为2013-5-31 19:40:00 或者 2013/5/31/ 19:40:00这种类型的吗?
Timestamp stamp = new Timestamp(1363355755000l);
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
String str = dateFormat.format(stamp);
这种形式的时间称为时间戳,具体参见时间戳描述
1970年到该时间的毫秒数,下面是ruby的实现
2.0.0p0 :006 > t = Time.at(1363355755000/1000)
=> 2013-03-15 21:55:55 +0800
java实现:
system.out.println( new java.text
.SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
.format(new java.util.Date(1363355755000l)));