Java OR Android
URL url=new URL("http://www.bjtime.cn");//取得资源对象
URLConnection uc=url.openConnection();//生成连接对象
uc.connect(); //发出连接
long ld=uc.getDate(); //取得网站日期时间
Date date=new Date(ld); //转换为标准时间对象
这段代码用于获取准确的北京时间(也就是东八区区时)
URL url=new URL("http://www.bjtime.cn");//取得资源对象
URLConnection uc=url.openConnection();//生成连接对象
uc.connect(); //发出连接
long ld=uc.getDate(); //取得网站日期时间
Date date=new Date(ld); //转换为标准时间对象
这段代码用于获取准确的北京时间(也就是东八区区时)