java获得网络时间的方法
yqxbc 发布时间:04-05 来源:一起学编程 浏览:8次

 一起学编程网(www.zftb.cn):java获得网络时间的方法

//取得资源对象
URL url = new URL("http://www.bjtime.cn");
//生成连接对象
URLConnection uc = url.openConnection();
//发出连接
uc.connect();
long time = uc.getDate();
System.out.println("long time:"+time);
Date date = new Date(time);
System.out.println("date:"+date.toString());
System.out.println(new SimpleDateFormat("yyyy-MM-dd hh-mm-ss").format(date));
 

如果你有好的win10资讯或者win10教程,以及win10相关的问题想要获得win10系统下载的关注与报道。
欢迎加入发送邮件到657025171#qq.com(#替换为@)。期待你的好消息!