Java 实例 - 获取 URL响应头的日期信息

Java 教程 · 2019-02-11 21:57:45

以下实例演示了如何使用 HttpURLConnection 的 httpCon.getDate() 方法来获取 URL响应头的日期信息:

Main.java 文件

import java.net.HttpURLConnection; import java.net.URL; import java.util.Date; public class Main{ public static void main(String args[]) throws Exception { URL url = new URL("http://www.codercto.com"); HttpURLConnection httpCon = (HttpURLConnection) url.openConnection(); long date = httpCon.getDate(); if (date == 0) System.out.println("无法获取信息。"); else System.out.println("Date: " + new Date(date)); } }

以上代码运行输出结果为:

Date: Mon May 04 11:57:06 CST 2015

点击查看所有 Java 教程 文章: https://codercto.com/courses/l/12.html

查看所有标签

Linux Device Drivers

Linux Device Drivers

Jonathan Corbet、Alessandro Rubini、Greg Kroah-Hartman / O'Reilly Media / 2005-2-17 / USD 39.95

Device drivers literally drive everything you're interested in--disks, monitors, keyboards, modems--everything outside the computer chip and memory. And writing device drivers is one of the few areas ......一起来看看 《Linux Device Drivers》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

MD5 加密
MD5 加密

MD5 加密工具