Here you can find the source of getRemoteTimestamp(final String url)
Parameter | Description |
---|---|
url | - The url of the resource we want to get its timestamp. |
public static long getRemoteTimestamp(final String url)
//package com.java2s; /*/*from w ww .j a va 2 s . co m*/ * This file is part of WaqtSalat-Service. * * WaqtSalat-Service is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WaqtSalat-Service is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WaqtSalat-Service. If not, see <http://www.gnu.org/licenses/>. */ import java.net.URL; import java.net.URLConnection; public class Main { /** * @param url * - The url of the resource we want to get its timestamp. * @return The timestamp (last modification date) of the specified * url/resource, -1L if an error occurred, 0L if not known. */ public static long getRemoteTimestamp(final String url) { try { URL u = new URL(url); URLConnection urlc = u.openConnection(); return urlc.getLastModified(); } catch (Exception e) { return -1L; } } }