public static long getLastModified(URL resourceURL) {
        final String protocol = resourceURL.getProtocol();
        switch (protocol) {
            case "jar":
                try {
                    final JarURLConnection jarConnection = (JarURLConnection) resourceURL.openConnection();
                    final JarEntry entry = jarConnection.getJarEntry();
                    return entry.getTime();
                } catch (IOException ignored) {
                }
                return 0;
            case "file":
                URLConnection connection = null;
                try {
                    connection = resourceURL.openConnection();
                    return connection.getLastModified();
                } catch (IOException ignored) {
                } finally {
                    if (connection != null) {
                        try {
                            connection.getInputStream().close();
                        } catch (IOException ignored) {
                        }
                    }
                }
                return 0;
            default:
                throw new IllegalArgumentException("Unsupported protocol " + protocol + " for resource " + resourceURL);
        }
    }
@Test
    void getLastModifiedReturnsZeroIfAnErrorOccurs() throws Exception {
        final URL url = new URL("file:/some/path/that/doesnt/exist");
        final long lastModified = ResourceURL.getLastModified(url);

        assertThat(lastModified)
                .isZero();
    }