URLConnection hpCon=hp.openConnection();
System.out.println("Last Modified: "+new Date(hpCon.getLastModified())); 用这样的方法得到的结果都是Last Modified: Thu Jan 01 08:00:00 CST 1970
很明显是错误的另外创建时间不知道如何获取
请各位指点下
System.out.println("Last Modified: "+new Date(hpCon.getLastModified())); 用这样的方法得到的结果都是Last Modified: Thu Jan 01 08:00:00 CST 1970
很明显是错误的另外创建时间不知道如何获取
请各位指点下
import java.net.URLConnection;
import java.net.URL;
import java.util.List;
import java.util.Map;/**
* 获取 HTTP HEADER 信息
*/
public class TestHttpHeader { public static void main(String[] args) throws Exception {
URLConnection conn = new URL("http://www.csdn.net").openConnection();
Map<String,List<String>> headers = conn.getHeaderFields();
for (String headerName : headers.keySet()) {
System.out.println(headerName + ": " + headers.get(headerName));
}
}
}
SimpleDateFormat sd=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time=sd.format(dd);
System.out.print(time);
导入的包分别是
import java.text.SimpleDateFormat;
import java.util.Date;