本文整理了Java中java.net.URLConnection.getDate()
方法的一些代码示例,展示了URLConnection.getDate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URLConnection.getDate()
方法的具体详情如下:
包路径:java.net.URLConnection
类名称:URLConnection
方法名:getDate
[英]Returns the timestamp when this response has been sent as a date in milliseconds since January 1, 1970 GMT or 0 if this timestamp is unknown.
[中]返回自1970年1月1日GMT或0(如果此时间戳未知)以来以毫秒为单位发送此响应的时间戳。
代码示例来源:origin: stackoverflow.com
Date serverTime = new Date(connection.getDate());
try {
CDate = df.format(serverTime);
代码示例来源:origin: jmaki/ajax-wrapper-comp
public long getDate() {
if (this.urlConnection == null) return -1;
return (this.urlConnection.getDate());
}
public String getHeader(String name) {
代码示例来源:origin: org.dihedron.commons/dihedron-commons
/**
* Returns the date of the response.
*
* @return
* the date of the response.
*/
public long getDate() {
return connection.getDate();
}
代码示例来源:origin: freeplane/freeplane
public long getDate() {
return connection.getDate();
}
代码示例来源:origin: org.eclipse.jetty.osgi/jetty-osgi-boot-warurl
@Override
public long getDate()
{
return _conn.getDate();
}
代码示例来源:origin: org.jboss/jboss-common-core
public long getDate() {
return delegateConnection.getDate();
}
代码示例来源:origin: org.microemu/microemu-javase
public long getDate() throws IOException {
if (cn == null) {
throw new IOException();
}
if (!connected) {
cn.connect();
connected = true;
}
return cn.getDate();
}
代码示例来源:origin: org.samba.jcifs/jcifs
public long getDate() {
try {
handshake();
} catch (IOException ex) { }
return connection.getDate();
}
代码示例来源:origin: zyAndroid/countdown
@Override
protected Long doInBackground(Long... longs) {
URL url = null;//取得资源对象
try {
url = new URL("http://www.bjtime.cn");
URLConnection uc = url.openConnection();
uc.connect();
time_net = uc.getDate();
if (time_net < longs[0]) {
return longs[0] - time_net;
} else {
return (long) 0;
}
} catch (Exception e) {
Log.d("countdown", "Exception: " + e);
}
return (long) 0;
}
代码示例来源:origin: knightliao/common-utils
/**
* 获取远程服务器日期
*
* @param url 链接地址
*
* <p>
* http://192.9.162.55
* <p>
* http://java.sun.com
* </p>
* @return 远程服务器日期,如果反生异常,返回当前日期
*/
public static Date getRemoteDate(String url) {
if (url == null) {
return null;
}
URLConnection uc;
try {
uc = new URL(url).openConnection();
uc.connect(); // 发出连接
return new Date(uc.getDate());// 生成连接对象
} catch (IOException e) {
return new Date();
}
}
代码示例来源:origin: apache/cxf
/**
* Finds the timestamp for a given URI. Calls {@link #getBaseFileURI(URI)} prior to the timestamp
* check in order to handle "classpath" and "jar" URIs.
*
* @param uri the URI to timestamp
* @return a timestamp
*/
protected long getTimestamp(URI uri) {
long timestamp = 0;
URI baseURI = getBaseFileURI(uri);
if ("file".equals(baseURI.getScheme())) {
timestamp = new File(baseURI).lastModified();
} else {
try {
timestamp = baseURI.toURL().openConnection().getDate();
} catch (Exception e) {
// ignore
}
}
return timestamp;
}
代码示例来源:origin: org.glassfish.external/schema2beans
private static long getLastModified(Class cls) {
try {
String shortName = cls.getName().substring(1+cls.getName().lastIndexOf('.'));
java.net.URL url = cls.getResource(shortName + ".class");
String file = url.getFile();
//System.out.println("url="+url);
if ("file".equals(url.getProtocol())) {
// example: file='/home/cliffwd/cvs/dublin/nb_all/schema2beans/rt/src/org/netbeans/modules/schema2beans/GenBeans.class'
String result = file.substring(0, file.length() - cls.getName().length() - 6);
return new File(file).lastModified();
} else if ("jar".equals(url.getProtocol())) {
// example: file = 'jar:/usr/local/j2sdkee1.3.1/lib/j2ee.jar!/org/w3c/dom/Node.class'
String jarFile = file.substring(file.indexOf(':')+1);
jarFile = jarFile.substring(0, jarFile.indexOf('!'));
//System.out.println("jarFile="+jarFile);
return new File(jarFile).lastModified();
}
return url.openConnection().getDate();
} catch (java.io.IOException e) {
return 0;
}
}
}
代码示例来源:origin: org.apache.cxf/cxf-codegen-plugin
/**
* Finds the timestamp for a given URI. Calls {@link #getBaseFileURI(URI)} prior to the timestamp
* check in order to handle "classpath" and "jar" URIs.
*
* @param uri the URI to timestamp
* @return a timestamp
*/
protected long getTimestamp(URI uri) {
long timestamp = 0;
URI baseURI = getBaseFileURI(uri);
if ("file".equals(baseURI.getScheme())) {
timestamp = new File(baseURI).lastModified();
} else {
try {
timestamp = baseURI.toURL().openConnection().getDate();
} catch (Exception e) {
// ignore
}
}
return timestamp;
}
代码示例来源:origin: apache/cxf
} else {
try {
timestamp = wsdlURI.toURL().openConnection().getDate();
} catch (Exception e) {
代码示例来源:origin: apache/cxf
} else {
try {
timestamp = wadlURI.toURL().openConnection().getDate();
} catch (Exception e) {
代码示例来源:origin: org.apache.cxf/cxf-codegen-plugin
} else {
try {
timestamp = wsdlURI.toURL().openConnection().getDate();
} catch (Exception e) {
代码示例来源:origin: stackoverflow.com
http = (HttpURLConnection) url.openConnection();
Log.i("getDate", "="+http.getDate());
http.connect();
result = convertStreamToString((InputStream)http.getContent());
代码示例来源:origin: com.github.houbie/rhino-mod
final long response_time = System.currentTimeMillis();
final long apparent_age = Math.max(0, response_time -
urlConnection.getDate());
final long corrected_received_age = Math.max(apparent_age,
urlConnection.getHeaderFieldInt("Age", 0) * 1000L);
代码示例来源:origin: io.apigee/rhino
final long response_time = System.currentTimeMillis();
final long apparent_age = Math.max(0, response_time -
urlConnection.getDate());
final long corrected_received_age = Math.max(apparent_age,
urlConnection.getHeaderFieldInt("Age", 0) * 1000L);
代码示例来源:origin: octo-online/reactive-audit
@Test(expected = NetworkReactiveAuditException.class)
public void getDate()
throws IOException
{
Assume.assumeTrue(IOTestTools.isNetworkConnected());
ReactiveAudit.off.commit();
URLConnection conn = new URL("http://" + HOST + ":" + PORT).openConnection();
TestTools.strict.commit();
conn.getDate();
}
内容来源于网络,如有侵权,请联系作者删除!