获取网络同步时间
来源:互联网 发布:怎么查看自己淘宝店铺 编辑:程序博客网 时间:2024/05/20 06:54
public static void main(String[] args) throws Exception {
URL url=new URL("http://www.bjtime.cn");//取得资源对象
URLConnection uc=url.openConnection();//生成连接对象
uc.connect(); //发出连接
long ld=uc.getDate(); //取得网站日期时间(时间戳)
Date date=new Date(ld); //转换为标准时间对象
System.out.print(date.getYear()+1900 + "年" +date.getMonth() + "月" + date.getDay() + "日" +
date.getHours() + "时" +date.getMinutes() +"分" + date.getSeconds() +"秒");
URL url=new URL("http://www.bjtime.cn");//取得资源对象
URLConnection uc=url.openConnection();//生成连接对象
uc.connect(); //发出连接
long ld=uc.getDate(); //取得网站日期时间(时间戳)
Date date=new Date(ld); //转换为标准时间对象
System.out.print(date.getYear()+1900 + "年" +date.getMonth() + "月" + date.getDay() + "日" +
date.getHours() + "时" +date.getMinutes() +"分" + date.getSeconds() +"秒");
}
public static void main(String[] args) throws Exception {
URL url=new URL("http://www.bjtime.cn");//取得资源对象
URLConnection uc=url.openConnection();//生成连接对象
uc.connect(); //发出连接
long ld=uc.getDate(); //取得网站日期时间(时间戳)
SimpleDateFormat sdf = new SimpleDateFormat("yyyy 年 MM 月 dd 日 hh 时 mm 分 ss 秒"); //设置格式化时间格式
String date = sdf.format(new Date(ld)); // 格式化时间
System.out.print(date);
}
1 0
- 获取网络同步时间
- android-获取网络时间、获取特定时区时间、时间同步
- windows获取网络时间,同步系统时间方法
- 获取网络时间(即获取网络时间同步服务器的时间)
- 获取网络时间、获取特定时区时间、时间同步GMT UTC
- android-获取网络时间、获取特定时区时间、时间同步的方法
- 网络时间同步
- C#同步网络时间
- C#同步网络时间
- C#同步网络时间
- C#同步网络时间
- C#同步网络时间
- 通过网络同步时间
- 通过网络同步时间
- CentOS同步网络时间
- NTP 网络时间同步
- Android网络时间同步
- 网络时间同步
- 第三方登录
- 树莓派hadoop集群搭建
- python 文件和文件夹操作 os模块和shutil模块
- Activity的Launch Mode
- Phalcon环境搭建
- 获取网络同步时间
- NSTimer
- Android 47个小知识
- 阅读BeautifulSoup笔记
- ArrayList集合的一个测试题(带答案)
- 160624
- 设计模式之代理模式
- Zookeeper分布式集群的安装与配置
- 剑指offer:两个栈组成一个队列