Use java.time.Duration for timeouts.

- [HTTP5] Add
Http5FileSystemConfigBuilder.setConnectionTimeout(FileSystemOptions,
Duration) and deprecate Integer version.
- [HTTP5] Add
Http5FileSystemConfigBuilder.setSoTimeout(FileSystemOptions, Duration)
and deprecate Integer version.
- [HTTP5] Add
Http5FileSystemConfigBuilder.getConnectionTimeoutDuration(FileSystemOptions)
and deprecate Integer version.
- [HTTP5] Add
Http5FileSystemConfigBuilder.getSoTimeoutDuration(FileSystemOptions) and
deprecate Integer version.
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileProvider.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileProvider.java
index 2f01431..b244f41 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileProvider.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileProvider.java
@@ -28,8 +28,6 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
-import java.util.concurrent.TimeUnit;
-
 import javax.net.ssl.HostnameVerifier;
 import javax.net.ssl.SSLContext;
 
@@ -77,6 +75,7 @@
 import org.apache.hc.core5.http.message.BasicHeader;
 import org.apache.hc.core5.http.ssl.TLS;
 import org.apache.hc.core5.ssl.SSLContextBuilder;
+import org.apache.hc.core5.util.Timeout;
 
 /**
  * {@code FileProvider} implementation using HttpComponents HttpClient v5 library.
@@ -119,7 +118,7 @@
         final SocketConfig socketConfig =
                 SocketConfig
                 .custom()
-                .setSoTimeout(builder.getSoTimeout(fileSystemOptions), TimeUnit.MILLISECONDS)
+                .setSoTimeout(Timeout.ofMilliseconds(builder.getSoTimeoutDuration(fileSystemOptions).toMillis()))
                 .build();
 
         final String[] tlsVersions = builder.getTlsVersions(fileSystemOptions).split("\\s*,\\s*");
@@ -155,7 +154,7 @@
     private RequestConfig createDefaultRequestConfig(final Http5FileSystemConfigBuilder builder,
             final FileSystemOptions fileSystemOptions) {
         return RequestConfig.custom()
-                .setConnectTimeout(builder.getConnectionTimeout(fileSystemOptions), TimeUnit.MILLISECONDS)
+                .setConnectTimeout(Timeout.ofMilliseconds(builder.getSoTimeoutDuration(fileSystemOptions).toMillis()))
                 .build();
     }
 
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileSystemConfigBuilder.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileSystemConfigBuilder.java
index 657cefc..642de71 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileSystemConfigBuilder.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileSystemConfigBuilder.java
@@ -17,6 +17,7 @@
 package org.apache.commons.vfs2.provider.http5;
 
 import java.security.KeyStore;
+import java.time.Duration;
 
 import org.apache.commons.vfs2.FileSystem;
 import org.apache.commons.vfs2.FileSystemConfigBuilder;
@@ -157,12 +158,12 @@
     /**
      * The default value for {@link #CONNECTION_TIMEOUT} configuration.
      */
-    private static final int DEFAULT_CONNECTION_TIMEOUT = 0;
+    private static final Duration DEFAULT_CONNECTION_TIMEOUT = Duration.ZERO;
 
     /**
      * The default value for {@link #SO_TIMEOUT} configuration.
      */
-    private static final int DEFAULT_SO_TIMEOUT = 0;
+    private static final Duration DEFAULT_SO_TIMEOUT = Duration.ZERO;
 
     /**
      * The default value for {@link #KEEP_ALIVE} configuration.
@@ -222,9 +223,22 @@
      *
      * @param opts The FileSystem options.
      * @return The connection timeout.
+     * @deprecated {@link #getConnectionTimeoutDuration(FileSystemOptions)}.
      */
+    @Deprecated
     public int getConnectionTimeout(final FileSystemOptions opts) {
-        return getInteger(opts, CONNECTION_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT);
+        return getDurationInteger(opts, CONNECTION_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT);
+    }
+
+    /**
+     * Gets the connection timeout.
+     *
+     * @param opts The FileSystem options.
+     * @return The connection timeout.
+     * @since 2.8.0
+     */
+    public Duration getConnectionTimeoutDuration(final FileSystemOptions opts) {
+        return getDuration(opts, CONNECTION_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT);
     }
 
     /**
@@ -348,9 +362,22 @@
      *
      * @param opts The FileSystemOptions.
      * @return The socket timeout.
+     * @deprecated Use {@link #getSoTimeoutDuration(FileSystemOptions)}.
      */
+    @Deprecated
     public int getSoTimeout(final FileSystemOptions opts) {
-        return getInteger(opts, SO_TIMEOUT, DEFAULT_SO_TIMEOUT);
+        return getDurationInteger(opts, SO_TIMEOUT, DEFAULT_SO_TIMEOUT);
+    }
+
+    /**
+     * Gets the socket timeout.
+     *
+     * @param opts The FileSystemOptions.
+     * @return The socket timeout.
+     * @since 2.8.0
+     */
+    public Duration getSoTimeoutDuration(final FileSystemOptions opts) {
+        return getDuration(opts, SO_TIMEOUT, DEFAULT_SO_TIMEOUT);
     }
 
     /**
@@ -417,13 +444,26 @@
     }
 
     /**
-     * The connection timeout.
+     * Sets the connection timeout.
      *
      * @param opts The FileSystem options.
      * @param connectionTimeout The connection timeout.
+     * @deprecated Use {@link #setConnectionTimeout(FileSystemOptions, Duration)}.
      */
+    @Deprecated
     public void setConnectionTimeout(final FileSystemOptions opts, final int connectionTimeout) {
-        setParam(opts, CONNECTION_TIMEOUT, Integer.valueOf(connectionTimeout));
+        setConnectionTimeout(opts, Duration.ofMillis(connectionTimeout));
+    }
+
+    /**
+     * Sets the connection timeout.
+     *
+     * @param opts The FileSystem options.
+     * @param connectionTimeout The connection timeout.
+     * @since 2.8.0
+     */
+    public void setConnectionTimeout(final FileSystemOptions opts, final Duration connectionTimeout) {
+        setParam(opts, CONNECTION_TIMEOUT, connectionTimeout);
     }
 
     /**
@@ -576,13 +616,25 @@
     }
 
     /**
+     * Sets the socket timeout.
+     *
+     * @param opts The FileSystem options.
+     * @param soTimeout socket timeout.
+     * @deprecated Use {@link #setSoTimeout(FileSystemOptions, Duration)}.
+     */
+    @Deprecated
+    public void setSoTimeout(final FileSystemOptions opts, final int soTimeout) {
+        setSoTimeout(opts, Duration.ofMillis(soTimeout));
+    }
+
+    /**
      * The socket timeout.
      *
      * @param opts The FileSystem options.
      * @param soTimeout socket timeout.
      */
-    public void setSoTimeout(final FileSystemOptions opts, final int soTimeout) {
-        setParam(opts, SO_TIMEOUT, Integer.valueOf(soTimeout));
+    public void setSoTimeout(final FileSystemOptions opts, final Duration soTimeout) {
+        setParam(opts, SO_TIMEOUT, soTimeout);
     }
 
     /**
diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http5/Http5ProviderTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http5/Http5ProviderTestCase.java
index e58a6f7..e449992 100644
--- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http5/Http5ProviderTestCase.java
+++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http5/Http5ProviderTestCase.java
@@ -17,6 +17,7 @@
 package org.apache.commons.vfs2.provider.http5;
 
 import java.io.File;
+import java.time.Duration;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.vfs2.AbstractProviderTestConfig;
@@ -142,15 +143,19 @@
     }
 
     /** Ensure VFS-453 options are present. */
+    @SuppressWarnings("deprecation")
     public void testHttpTimeoutConfig() {
         final FileSystemOptions opts = new FileSystemOptions();
         final Http5FileSystemConfigBuilder builder = Http5FileSystemConfigBuilder.getInstance();
 
         // ensure defaults are 0
         assertEquals(0, builder.getConnectionTimeout(opts));
+        assertEquals(Duration.ZERO, builder.getConnectionTimeoutDuration(opts));
         assertEquals(0, builder.getSoTimeout(opts));
+        assertEquals(Duration.ZERO, builder.getSoTimeoutDuration(opts));
         assertEquals("Jakarta-Commons-VFS", builder.getUserAgent(opts));
 
+        // timeout as int
         builder.setConnectionTimeout(opts, 60000);
         builder.setSoTimeout(opts, 60000);
         builder.setUserAgent(opts, "foo/bar");
@@ -160,6 +165,15 @@
         assertEquals(60000, builder.getSoTimeout(opts));
         assertEquals("foo/bar", builder.getUserAgent(opts));
 
+        // timeout as Duration
+        builder.setConnectionTimeout(opts, Duration.ofMinutes(1));
+        builder.setSoTimeout(opts, Duration.ofMinutes(1));
+        builder.setUserAgent(opts, "foo/bar");
+
+        // ensure changes are visible
+        assertEquals(60000, builder.getConnectionTimeoutDuration(opts).toMillis());
+        assertEquals(60000, builder.getSoTimeoutDuration(opts).toMillis());
+        assertEquals("foo/bar", builder.getUserAgent(opts));
     }
 
     private void testResloveFolderSlash(final String uri, final boolean followRedirect) throws FileSystemException {
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index eb41a47..16df538 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -142,6 +142,18 @@
       <action dev="ggregory" due-to="Gary Gregory" type="add">
         [HTTP4] Add Http4FileSystemConfigBuilder.getSoTimeoutDuration(FileSystemOptions) and deprecate Integer version.
       </action>
+      <action dev="ggregory" due-to="Gary Gregory" type="add">
+        [HTTP5] Add Http5FileSystemConfigBuilder.setConnectionTimeout(FileSystemOptions, Duration) and deprecate Integer version.
+      </action>
+      <action dev="ggregory" due-to="Gary Gregory" type="add">
+        [HTTP5] Add Http5FileSystemConfigBuilder.setSoTimeout(FileSystemOptions, Duration) and deprecate Integer version.
+      </action>
+      <action dev="ggregory" due-to="Gary Gregory" type="add">
+        [HTTP5] Add Http5FileSystemConfigBuilder.getConnectionTimeoutDuration(FileSystemOptions) and deprecate Integer version.
+      </action>
+      <action dev="ggregory" due-to="Gary Gregory" type="add">
+        [HTTP5] Add Http5FileSystemConfigBuilder.getSoTimeoutDuration(FileSystemOptions) and deprecate Integer version.
+      </action>
       <!-- UPDATES -->
       <action dev="ggregory" due-to="PeterAlfredLee" type="update">
         Modify some code use for-each loop and stream API #142.