Index: trunk/src/oauth/signpost/AbstractOAuthConsumer.java
===================================================================
--- trunk/src/oauth/signpost/AbstractOAuthConsumer.java	(revision 11287)
+++ trunk/src/oauth/signpost/AbstractOAuthConsumer.java	(revision 11288)
@@ -18,4 +18,5 @@
 import java.io.InputStream;
 import java.util.Random;
+import java.util.concurrent.TimeUnit;
 
 import oauth.signpost.basic.UrlStringRequestAdapter;
@@ -267,5 +268,5 @@
 
     protected String generateTimestamp() {
-        return Long.toString(System.currentTimeMillis() / 1000L);
+        return Long.toString(System.currentTimeMillis() / TimeUnit.SECONDS.toMillis(1));
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 11288)
@@ -15,4 +15,5 @@
 import java.util.HashSet;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 import javax.swing.JOptionPane;
@@ -312,5 +313,6 @@
 
     private BoundingXYVisitor modeDownload(BoundingXYVisitor v) {
-        if (lastZoomTime > 0 && System.currentTimeMillis() - lastZoomTime > Main.pref.getLong("zoom.bounds.reset.time", 10L*1000L)) {
+        if (lastZoomTime > 0 &&
+                System.currentTimeMillis() - lastZoomTime > Main.pref.getLong("zoom.bounds.reset.time", TimeUnit.SECONDS.toMillis(10))) {
             lastZoomTime = -1;
         }
Index: trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java	(revision 11288)
@@ -1204,5 +1204,5 @@
         @Override
         protected Long getNumber(OsmPrimitive osm) {
-            return osm.getRawTimestamp() * 1000L;
+            return osm.getTimestamp().getTime();
         }
 
Index: trunk/src/org/openstreetmap/josm/data/AutosaveTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/AutosaveTask.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/data/AutosaveTask.java	(revision 11288)
@@ -26,4 +26,5 @@
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
 import java.util.regex.Pattern;
 
@@ -75,5 +76,5 @@
     public static final IntegerProperty PROP_FILES_PER_LAYER = new IntegerProperty("autosave.filesPerLayer", 1);
     public static final IntegerProperty PROP_DELETED_LAYERS = new IntegerProperty("autosave.deletedLayersBackupCount", 5);
-    public static final IntegerProperty PROP_INTERVAL = new IntegerProperty("autosave.interval", 5 * 60);
+    public static final IntegerProperty PROP_INTERVAL = new IntegerProperty("autosave.interval", (int) TimeUnit.MINUTES.toSeconds(5));
     public static final IntegerProperty PROP_INDEX_LIMIT = new IntegerProperty("autosave.index-limit", 1000);
     /** Defines if a notification should be displayed after each autosave */
@@ -131,5 +132,5 @@
             }
 
-            new Timer(true).schedule(this, 1000L, PROP_INTERVAL.get() * 1000L);
+            new Timer(true).schedule(this, TimeUnit.SECONDS.toMillis(1), TimeUnit.SECONDS.toMillis(PROP_INTERVAL.get()));
             Main.getLayerManager().addLayerChangeListener(this, true);
         }
Index: trunk/src/org/openstreetmap/josm/data/Preferences.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 11288)
@@ -36,4 +36,5 @@
 import java.util.SortedMap;
 import java.util.TreeMap;
+import java.util.concurrent.TimeUnit;
 import java.util.function.Predicate;
 import java.util.regex.Matcher;
@@ -105,5 +106,5 @@
     };
 
-    private static final long MAX_AGE_DEFAULT_PREFERENCES = 60L * 60L * 24L * 50L; // 50 days (in seconds)
+    private static final long MAX_AGE_DEFAULT_PREFERENCES = TimeUnit.DAYS.toSeconds(50);
 
     /**
Index: trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java	(revision 11288)
@@ -47,10 +47,10 @@
 public abstract class JCSCachedTileLoaderJob<K, V extends CacheEntry> implements ICachedLoaderJob<K> {
     private static final Logger LOG = FeatureAdapter.getLogger(JCSCachedTileLoaderJob.class.getCanonicalName());
-    protected static final long DEFAULT_EXPIRE_TIME = 1000L * 60 * 60 * 24 * 7; // 7 days
+    protected static final long DEFAULT_EXPIRE_TIME = TimeUnit.DAYS.toMillis(7);
     // Limit for the max-age value send by the server.
-    protected static final long EXPIRE_TIME_SERVER_LIMIT = 1000L * 60 * 60 * 24 * 28; // 4 weeks
+    protected static final long EXPIRE_TIME_SERVER_LIMIT = TimeUnit.DAYS.toMillis(28);
     // Absolute expire time limit. Cached tiles that are older will not be used,
     // even if the refresh from the server fails.
-    protected static final long ABSOLUTE_EXPIRE_TIME_LIMIT = 1000L * 60 * 60 * 24 * 365; // 1 year
+    protected static final long ABSOLUTE_EXPIRE_TIME_LIMIT = TimeUnit.DAYS.toMillis(365);
 
     /**
@@ -432,6 +432,5 @@
                     for (String token: str.split(",")) {
                         if (token.startsWith("max-age=")) {
-                            lng = Long.parseLong(token.substring(8)) * 1000 +
-                                    System.currentTimeMillis();
+                            lng = TimeUnit.SECONDS.toMillis(Long.parseLong(token.substring(8))) + System.currentTimeMillis();
                         }
                     }
Index: trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java	(revision 11288)
@@ -6,4 +6,5 @@
 import java.util.Collections;
 import java.util.Date;
+import java.util.DoubleSummaryStatistics;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -18,5 +19,4 @@
 import org.openstreetmap.josm.data.DataSource;
 import org.openstreetmap.josm.data.coor.EastNorth;
-import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -193,21 +193,11 @@
      */
     public static Date[] getMinMaxTimeForTrack(GpxTrack trk) {
-        WayPoint earliest = null, latest = null;
-
-        for (GpxTrackSegment seg : trk.getSegments()) {
-            for (WayPoint pnt : seg.getWayPoints()) {
-                if (latest == null) {
-                    latest = earliest = pnt;
-                } else {
-                    if (pnt.compareTo(earliest) < 0) {
-                        earliest = pnt;
-                    } else if (pnt.compareTo(latest) > 0) {
-                        latest = pnt;
-                    }
-                }
-            }
-        }
-        if (earliest == null || latest == null) return null;
-        return new Date[]{earliest.getTime(), latest.getTime()};
+        final DoubleSummaryStatistics statistics = trk.getSegments().stream()
+                .flatMap(seg -> seg.getWayPoints().stream())
+                .mapToDouble(pnt -> pnt.time)
+                .summaryStatistics();
+        return statistics.getCount() == 0
+                ? null
+                : new Date[]{new Date((long) (statistics.getMin() * 1000)), new Date((long) (statistics.getMax() * 1000))};
     }
 
@@ -220,20 +210,14 @@
     */
     public Date[] getMinMaxTimeForAllTracks() {
-        double min = 1e100;
-        double max = -1e100;
-        double now = System.currentTimeMillis()/1000.0;
-        for (GpxTrack trk: tracks) {
-            for (GpxTrackSegment seg : trk.getSegments()) {
-                for (WayPoint pnt : seg.getWayPoints()) {
-                    double t = pnt.time;
-                    if (t > 0 && t <= now) {
-                        if (t > max) max = t;
-                        if (t < min) min = t;
-                    }
-                }
-            }
-        }
-        if (Utils.equalsEpsilon(min, 1e100) || Utils.equalsEpsilon(max, -1e100)) return new Date[0];
-        return new Date[]{new Date((long) (min * 1000)), new Date((long) (max * 1000))};
+        double now = System.currentTimeMillis() / 1000.0;
+        final DoubleSummaryStatistics statistics = tracks.stream()
+                .flatMap(trk -> trk.getSegments().stream())
+                .flatMap(seg -> seg.getWayPoints().stream())
+                .mapToDouble(pnt -> pnt.time)
+                .filter(t -> t > 0 && t <= now)
+                .summaryStatistics();
+        return statistics.getCount() == 0
+                ? new Date[0]
+                : new Date[]{new Date((long) (statistics.getMin() * 1000)), new Date((long) (statistics.getMax() * 1000))};
     }
 
Index: trunk/src/org/openstreetmap/josm/data/imagery/CachedAttributionBingAerialTileSource.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/imagery/CachedAttributionBingAerialTileSource.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/data/imagery/CachedAttributionBingAerialTileSource.java	(revision 11288)
@@ -7,4 +7,5 @@
 import java.util.List;
 import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
 
 import org.openstreetmap.gui.jmapviewer.tilesources.BingAerialTileSource;
@@ -75,5 +76,5 @@
                 } catch (IOException ex) {
                     Main.warn(ex, "Could not connect to Bing API. Will retry in " + waitTimeSec + " seconds.");
-                    Thread.sleep(waitTimeSec * 1000L);
+                    Thread.sleep(TimeUnit.SECONDS.toMillis(waitTimeSec));
                     waitTimeSec *= 2;
                 }
Index: trunk/src/org/openstreetmap/josm/data/imagery/CachedTileLoaderFactory.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/imagery/CachedTileLoaderFactory.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/data/imagery/CachedTileLoaderFactory.java	(revision 11288)
@@ -6,4 +6,5 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.jcs.access.behavior.ICacheAccess;
@@ -70,6 +71,6 @@
 
         return getLoader(listener, cache,
-                Main.pref.getInteger("socket.timeout.connect", 15) * 1000,
-                Main.pref.getInteger("socket.timeout.read", 30) * 1000,
+                (int) TimeUnit.SECONDS.toMillis(Main.pref.getInteger("socket.timeout.connect", 15)),
+                (int) TimeUnit.SECONDS.toMillis(Main.pref.getInteger("socket.timeout.read", 30)),
                 headers);
     }
Index: trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java	(revision 11288)
@@ -15,4 +15,5 @@
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -42,8 +43,6 @@
 public class TMSCachedTileLoaderJob extends JCSCachedTileLoaderJob<String, BufferedImageCacheEntry> implements TileJob, ICachedLoaderListener {
     private static final Logger LOG = FeatureAdapter.getLogger(TMSCachedTileLoaderJob.class.getCanonicalName());
-    private static final LongProperty MAXIMUM_EXPIRES = new LongProperty("imagery.generic.maximum_expires",
-            30 /*days*/ * 24 /*hours*/ * 60 /*minutes*/ * 60 /*seconds*/ *1000L /*milliseconds*/);
-    private static final LongProperty MINIMUM_EXPIRES = new LongProperty("imagery.generic.minimum_expires",
-            1 /*hour*/ * 60 /*minutes*/ * 60 /*seconds*/ *1000L /*milliseconds*/);
+    private static final LongProperty MAXIMUM_EXPIRES = new LongProperty("imagery.generic.maximum_expires", TimeUnit.DAYS.toMillis(30));
+    private static final LongProperty MINIMUM_EXPIRES = new LongProperty("imagery.generic.minimum_expires", TimeUnit.HOURS.toMillis(1));
     private final Tile tile;
     private volatile URL url;
Index: trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java	(revision 11288)
@@ -14,4 +14,5 @@
 import java.util.Objects;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -249,5 +250,5 @@
     @Override
     public void setTimestamp(Date timestamp) {
-        this.timestamp = (int) (timestamp.getTime() / 1000);
+        this.timestamp = (int) TimeUnit.MILLISECONDS.toSeconds(timestamp.getTime());
     }
 
@@ -259,5 +260,5 @@
     @Override
     public Date getTimestamp() {
-        return new Date(timestamp * 1000L);
+        return new Date(TimeUnit.SECONDS.toMillis(timestamp));
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java	(revision 11288)
@@ -16,4 +16,5 @@
 import java.util.LinkedList;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 import javax.swing.Action;
@@ -149,5 +150,5 @@
         hcbUploadComment.addCurrentItemToHistory();
         Main.pref.putCollection(HISTORY_KEY, hcbUploadComment.getHistory());
-        Main.pref.putInteger(HISTORY_LAST_USED_KEY, (int) (System.currentTimeMillis() / 1000));
+        Main.pref.putInteger(HISTORY_LAST_USED_KEY, (int) (TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())));
         // store the history of sources
         hcbUploadSource.addCurrentItemToHistory();
Index: trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java	(revision 11288)
@@ -25,4 +25,5 @@
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.concurrent.TimeUnit;
 
 import javax.swing.AbstractAction;
@@ -640,5 +641,5 @@
         Collection<String> history = Main.pref.getCollection(historyKey, def);
         int age = (int) (System.currentTimeMillis() / 1000 - Main.pref.getInteger(BasicUploadSettingsPanel.HISTORY_LAST_USED_KEY, 0));
-        if (age < Main.pref.getInteger(BasicUploadSettingsPanel.HISTORY_MAX_AGE_KEY, 4 * 3600 * 1000) && history != null && !history.isEmpty()) {
+        if (age < Main.pref.getLong(BasicUploadSettingsPanel.HISTORY_MAX_AGE_KEY, TimeUnit.HOURS.toMillis(4)) && history != null && !history.isEmpty()) {
             return history.iterator().next();
         } else {
Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java	(revision 11288)
@@ -38,4 +38,5 @@
 import java.util.Objects;
 import java.util.TimeZone;
+import java.util.concurrent.TimeUnit;
 import java.util.zip.GZIPInputStream;
 
@@ -408,7 +409,7 @@
                 TimeZone tz = TimeZone.getTimeZone(tzStr);
 
-                String tzDesc = new StringBuilder(tzStr).append(" (")
-                .append(new Timezone(tz.getRawOffset() / 3600000.0).formatTimezone())
-                .append(')').toString();
+                String tzDesc = tzStr + " (" +
+                        new Timezone(((double) tz.getRawOffset()) / TimeUnit.HOURS.toMillis(1)).formatTimezone() +
+                        ')';
                 vtTimezones.add(tzDesc);
             }
@@ -426,7 +427,7 @@
             }
 
-            cbTimezones.setSelectedItem(new StringBuilder(defaultTz.getID()).append(" (")
-                    .append(new Timezone(defaultTz.getRawOffset() / 3600000.0).formatTimezone())
-                    .append(')').toString());
+            cbTimezones.setSelectedItem(defaultTz.getID() + " (" +
+                    new Timezone(((double) defaultTz.getRawOffset()) / TimeUnit.HOURS.toMillis(1)).formatTimezone() +
+                    ')');
 
             gc.gridx = 1;
@@ -815,5 +816,5 @@
                 return tr("No gpx selected");
 
-            final long offsetMs = ((long) (timezone.getHours() * 3600 * 1000)) + delta.getMilliseconds(); // in milliseconds
+            final long offsetMs = ((long) (timezone.getHours() * TimeUnit.HOURS.toMillis(1))) + delta.getMilliseconds(); // in milliseconds
             lastNumMatched = matchGpxTrack(dateImgLst, selGpx.data, offsetMs);
 
@@ -846,5 +847,5 @@
 
             final Offset offset = Offset.milliseconds(
-                    delta.getMilliseconds() + Math.round(timezone.getHours() * 60 * 60 * 1000));
+                    delta.getMilliseconds() + Math.round(timezone.getHours() * TimeUnit.HOURS.toMillis(1)));
             final int dayOffset = offset.getDayOffset();
             final Pair<Timezone, Offset> timezoneOffsetPair = offset.withoutDayOffset().splitOutTimezone();
@@ -897,6 +898,6 @@
 
                     delta = Offset.milliseconds(100L * sldSeconds.getValue()
-                            + 1000L * 60 * sldMinutes.getValue()
-                            + 1000L * 60 * 60 * 24 * dayOffset);
+                            + TimeUnit.MINUTES.toMillis(sldMinutes.getValue())
+                            + TimeUnit.DAYS.toMillis(dayOffset));
 
                     tfTimezone.getDocument().removeDocumentListener(statusBarUpdater);
@@ -1146,5 +1147,5 @@
         // Time between the track point and the previous one, 5 sec if first point, i.e. photos take
         // 5 sec before the first track point can be assumed to be take at the starting position
-        long interval = prevWpTime > 0 ? Math.abs(curWpTime - prevWpTime) : 5*1000;
+        long interval = prevWpTime > 0 ? Math.abs(curWpTime - prevWpTime) : TimeUnit.SECONDS.toMillis(5);
         int ret = 0;
 
@@ -1432,22 +1433,20 @@
 
         int getDayOffset() {
-            final double diffInH = getMilliseconds() / 1000. / 60 / 60; // hours
-
             // Find day difference
-            return (int) Math.round(diffInH / 24);
+            return (int) Math.round(((double) getMilliseconds()) / TimeUnit.DAYS.toMillis(1));
         }
 
         Offset withoutDayOffset() {
-            return milliseconds(getMilliseconds() - getDayOffset() * 24L * 60L * 60L * 1000L);
+            return milliseconds(getMilliseconds() - TimeUnit.DAYS.toMillis(getDayOffset()));
         }
 
         Pair<Timezone, Offset> splitOutTimezone() {
             // In hours
-            double tz = withoutDayOffset().getSeconds() / 3600.0;
+            final double tz = ((double) withoutDayOffset().getSeconds()) / TimeUnit.HOURS.toSeconds(1);
 
             // Due to imprecise clocks we might get a "+3:28" timezone, which should obviously be 3:30 with
             // -2 minutes offset. This determines the real timezone and finds offset.
             final double timezone = (double) Math.round(tz * 2) / 2; // hours, rounded to one decimal place
-            final long delta = Math.round(getMilliseconds() - timezone * 60 * 60 * 1000); // milliseconds
+            final long delta = Math.round(getMilliseconds() - timezone * TimeUnit.HOURS.toMillis(1));
             return Pair.create(new Timezone(timezone), Offset.milliseconds(delta));
         }
Index: trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java	(revision 11288)
@@ -9,4 +9,5 @@
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
+import java.util.concurrent.TimeUnit;
 
 import org.openstreetmap.josm.Main;
@@ -25,11 +26,11 @@
     public static final int INTERVAL_ALWAYS = -1;
     /** Update interval meaning an update is needed each hour */
-    public static final int INTERVAL_HOURLY = 60*60;
+    public static final int INTERVAL_HOURLY = (int) TimeUnit.HOURS.toSeconds(1);
     /** Update interval meaning an update is needed each day */
-    public static final int INTERVAL_DAILY = INTERVAL_HOURLY * 24;
+    public static final int INTERVAL_DAILY = (int) TimeUnit.DAYS.toSeconds(1);
     /** Update interval meaning an update is needed each week */
-    public static final int INTERVAL_WEEKLY = INTERVAL_DAILY * 7;
+    public static final int INTERVAL_WEEKLY = (int) TimeUnit.DAYS.toSeconds(7);
     /** Update interval meaning an update is needed each month */
-    public static final int INTERVAL_MONTHLY = INTERVAL_WEEKLY * 4;
+    public static final int INTERVAL_MONTHLY = (int) TimeUnit.DAYS.toSeconds(28);
     /** Update interval meaning an update is never needed */
     public static final int INTERVAL_NEVER = Integer.MAX_VALUE;
@@ -88,5 +89,5 @@
             return false;
         }
-        return Main.pref.getInteger("cache." + ident, 0) + updateInterval < System.currentTimeMillis()/1000
+        return Main.pref.getInteger("cache." + ident, 0) + updateInterval < TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())
                 || !isCacheValid();
     }
@@ -136,5 +137,5 @@
         this.data = updateData();
         saveToDisk();
-        Main.pref.putInteger("cache." + ident, (int) (System.currentTimeMillis()/1000));
+        Main.pref.putInteger("cache." + ident, (int) (TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())));
         return data;
     }
Index: trunk/src/org/openstreetmap/josm/io/CachedFile.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/CachedFile.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/io/CachedFile.java	(revision 11288)
@@ -24,4 +24,5 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
@@ -76,5 +77,5 @@
 
     public static final long DEFAULT_MAXTIME = -1L;
-    public static final long DAYS = 24L*60L*60L; // factor to get caching time in days
+    public static final long DAYS = TimeUnit.DAYS.toSeconds(1); // factor to get caching time in days
 
     private final Map<String, String> httpHeaders = new ConcurrentHashMap<>();
@@ -417,5 +418,5 @@
         String urlStr = url.toExternalForm();
         long age = 0L;
-        long lMaxAge = maxAge;
+        long maxAgeMillis = maxAge;
         Long ifModifiedSince = null;
         File localFile = null;
@@ -436,8 +437,8 @@
                         || maxAge <= 0 // arbitrary value <= 0 is deprecated
                 ) {
-                    lMaxAge = Main.pref.getInteger("mirror.maxtime", 7*24*60*60); // one week
+                    maxAgeMillis = TimeUnit.SECONDS.toMillis(Main.pref.getLong("mirror.maxtime", TimeUnit.DAYS.toSeconds(7)));
                 }
                 age = System.currentTimeMillis() - Long.parseLong(localPathEntry.get(0));
-                if (offline || age < lMaxAge*1000) {
+                if (offline || age < maxAgeMillis) {
                     return localFile;
                 }
@@ -498,5 +499,5 @@
             }
         } catch (IOException e) {
-            if (age >= lMaxAge*1000 && age < lMaxAge*1000*2) {
+            if (age >= maxAgeMillis && age < maxAgeMillis*2) {
                 Main.warn(tr("Failed to load {0}, use cached file and retry next time: {1}", urlStr, e));
                 return localFile;
Index: trunk/src/org/openstreetmap/josm/io/MessageNotifier.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/MessageNotifier.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/io/MessageNotifier.java	(revision 11288)
@@ -93,5 +93,5 @@
             Main.info(tr("{0} not available (offline mode)", tr("Message notifier")));
         } else if (!isRunning() && interval > 0 && isUserEnoughIdentified()) {
-            task = EXECUTOR.scheduleAtFixedRate(WORKER, 0, interval * 60L, TimeUnit.SECONDS);
+            task = EXECUTOR.scheduleAtFixedRate(WORKER, 0, TimeUnit.MINUTES.toSeconds(interval), TimeUnit.SECONDS);
             Main.info("Message notifier active (checks every "+interval+" minute"+(interval > 1 ? "s" : "")+')');
         }
Index: trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java	(revision 11288)
@@ -11,4 +11,5 @@
 import java.util.LinkedList;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 import org.openstreetmap.josm.data.osm.Changeset;
@@ -64,8 +65,4 @@
     private boolean canceled;
 
-    private static final int MSECS_PER_SECOND = 1000;
-    private static final int SECONDS_PER_MINUTE = 60;
-    private static final int MSECS_PER_MINUTE = MSECS_PER_SECOND * SECONDS_PER_MINUTE;
-
     private long uploadStartTime;
 
@@ -79,6 +76,6 @@
         double uploadsLeft = (double) listSize - progress;
         long msLeft = (long) (uploadsLeft / uploadsPerMs);
-        long minutesLeft = msLeft / MSECS_PER_MINUTE;
-        long secondsLeft = (msLeft / MSECS_PER_SECOND) % SECONDS_PER_MINUTE;
+        long minutesLeft = msLeft / TimeUnit.MINUTES.toMillis(1);
+        long secondsLeft = (msLeft / TimeUnit.SECONDS.toMillis(1)) % TimeUnit.MINUTES.toSeconds(1);
         StringBuilder timeLeftStr = new StringBuilder().append(minutesLeft).append(':');
         if (secondsLeft < 10) {
Index: trunk/src/org/openstreetmap/josm/io/OverpassDownloadReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/OverpassDownloadReader.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/io/OverpassDownloadReader.java	(revision 11288)
@@ -9,4 +9,5 @@
 import java.util.List;
 import java.util.NoSuchElementException;
+import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -132,7 +133,7 @@
         final int timeout;
         if (timeoutMatcher.find()) {
-            timeout = 1000 * Integer.parseInt(timeoutMatcher.group(1));
+            timeout = (int) TimeUnit.SECONDS.toMillis(Integer.parseInt(timeoutMatcher.group(1)));
         } else {
-            timeout = 180_000;
+            timeout = (int) TimeUnit.MINUTES.toMillis(3);
         }
         request.setConnectTimeout(timeout);
Index: trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java	(revision 11288)
@@ -37,4 +37,5 @@
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.FutureTask;
+import java.util.concurrent.TimeUnit;
 import java.util.jar.JarFile;
 import java.util.stream.Collectors;
@@ -384,5 +385,5 @@
             long last = Main.pref.getLong("pluginmanager.lastupdate", 0);
             Integer maxTime = Main.pref.getInteger("pluginmanager.time-based-update.interval", DEFAULT_TIME_BASED_UPDATE_INTERVAL);
-            long d = (tim - last) / (24 * 60 * 60 * 1000L);
+            long d = TimeUnit.MILLISECONDS.toDays(tim - last);
             if ((last <= 0) || (maxTime <= 0)) {
                 Main.pref.put("pluginmanager.lastupdate", Long.toString(tim));
Index: trunk/src/org/openstreetmap/josm/tools/ExifReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/ExifReader.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/tools/ExifReader.java	(revision 11288)
@@ -6,4 +6,5 @@
 import java.io.IOException;
 import java.util.Date;
+import java.util.concurrent.TimeUnit;
 
 import org.openstreetmap.josm.Main;
@@ -70,5 +71,5 @@
                 if (subSeconds != null) {
                     try {
-                        date.setTime(date.getTime() + (long) (1000L * Double.parseDouble("0." + subSeconds)));
+                        date.setTime(date.getTime() + (long) (TimeUnit.SECONDS.toMillis(1) * Double.parseDouble("0." + subSeconds)));
                     } catch (NumberFormatException e) {
                         Main.warn("Failed parsing sub seconds from [{0}]", subSeconds);
Index: trunk/src/org/openstreetmap/josm/tools/HttpClient.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 11288)
@@ -21,4 +21,5 @@
 import java.util.Scanner;
 import java.util.TreeMap;
+import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -43,6 +44,6 @@
     private URL url;
     private final String requestMethod;
-    private int connectTimeout = Main.pref.getInteger("socket.timeout.connect", 15) * 1000;
-    private int readTimeout = Main.pref.getInteger("socket.timeout.read", 30) * 1000;
+    private int connectTimeout = (int) TimeUnit.SECONDS.toMillis(Main.pref.getInteger("socket.timeout.connect", 15));
+    private int readTimeout = (int) TimeUnit.SECONDS.toMillis(Main.pref.getInteger("socket.timeout.read", 30));
     private byte[] requestBody;
     private long ifModifiedSince;
Index: trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 11288)
@@ -47,4 +47,5 @@
 import java.util.concurrent.ForkJoinWorkerThread;
 import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.function.Function;
@@ -79,8 +80,8 @@
     public static final Pattern WHITE_SPACES_PATTERN = Pattern.compile("\\s+");
 
-    private static final int MILLIS_OF_SECOND = 1000;
-    private static final int MILLIS_OF_MINUTE = 60_000;
-    private static final int MILLIS_OF_HOUR = 3_600_000;
-    private static final int MILLIS_OF_DAY = 86_400_000;
+    private static final long MILLIS_OF_SECOND = TimeUnit.SECONDS.toMillis(1);
+    private static final long MILLIS_OF_MINUTE = TimeUnit.MINUTES.toMillis(1);
+    private static final long MILLIS_OF_HOUR = TimeUnit.HOURS.toMillis(1);
+    private static final long MILLIS_OF_DAY = TimeUnit.DAYS.toMillis(1);
 
     /**
Index: trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java	(revision 11287)
+++ trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java	(revision 11288)
@@ -13,4 +13,5 @@
 import java.util.Locale;
 import java.util.TimeZone;
+import java.util.concurrent.TimeUnit;
 
 import javax.xml.datatype.DatatypeConfigurationException;
@@ -145,5 +146,5 @@
      */
     public static synchronized String fromTimestamp(int timestamp) {
-        final ZonedDateTime temporal = Instant.ofEpochMilli(timestamp * 1000L).atZone(ZoneOffset.UTC);
+        final ZonedDateTime temporal = Instant.ofEpochMilli(TimeUnit.SECONDS.toMillis(timestamp)).atZone(ZoneOffset.UTC);
         return DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(temporal);
     }
