Changeset 11288 in josm for trunk/src/org


Ignore:
Timestamp:
2016-11-20T17:33:33+01:00 (8 years ago)
Author:
simon04
Message:

see #13376 - Use TimeUnit instead of combinations of 1000/60/60/24

Location:
trunk/src/org/openstreetmap/josm
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java

    r10601 r11288  
    1515import java.util.HashSet;
    1616import java.util.List;
     17import java.util.concurrent.TimeUnit;
    1718
    1819import javax.swing.JOptionPane;
     
    312313
    313314    private BoundingXYVisitor modeDownload(BoundingXYVisitor v) {
    314         if (lastZoomTime > 0 && System.currentTimeMillis() - lastZoomTime > Main.pref.getLong("zoom.bounds.reset.time", 10L*1000L)) {
     315        if (lastZoomTime > 0 &&
     316                System.currentTimeMillis() - lastZoomTime > Main.pref.getLong("zoom.bounds.reset.time", TimeUnit.SECONDS.toMillis(10))) {
    315317            lastZoomTime = -1;
    316318        }
  • trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r11192 r11288  
    12041204        @Override
    12051205        protected Long getNumber(OsmPrimitive osm) {
    1206             return osm.getRawTimestamp() * 1000L;
     1206            return osm.getTimestamp().getTime();
    12071207        }
    12081208
  • trunk/src/org/openstreetmap/josm/data/AutosaveTask.java

    r10938 r11288  
    2626import java.util.concurrent.ExecutionException;
    2727import java.util.concurrent.Future;
     28import java.util.concurrent.TimeUnit;
    2829import java.util.regex.Pattern;
    2930
     
    7576    public static final IntegerProperty PROP_FILES_PER_LAYER = new IntegerProperty("autosave.filesPerLayer", 1);
    7677    public static final IntegerProperty PROP_DELETED_LAYERS = new IntegerProperty("autosave.deletedLayersBackupCount", 5);
    77     public static final IntegerProperty PROP_INTERVAL = new IntegerProperty("autosave.interval", 5 * 60);
     78    public static final IntegerProperty PROP_INTERVAL = new IntegerProperty("autosave.interval", (int) TimeUnit.MINUTES.toSeconds(5));
    7879    public static final IntegerProperty PROP_INDEX_LIMIT = new IntegerProperty("autosave.index-limit", 1000);
    7980    /** Defines if a notification should be displayed after each autosave */
     
    131132            }
    132133
    133             new Timer(true).schedule(this, 1000L, PROP_INTERVAL.get() * 1000L);
     134            new Timer(true).schedule(this, TimeUnit.SECONDS.toMillis(1), TimeUnit.SECONDS.toMillis(PROP_INTERVAL.get()));
    134135            Main.getLayerManager().addLayerChangeListener(this, true);
    135136        }
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r11162 r11288  
    3636import java.util.SortedMap;
    3737import java.util.TreeMap;
     38import java.util.concurrent.TimeUnit;
    3839import java.util.function.Predicate;
    3940import java.util.regex.Matcher;
     
    105106    };
    106107
    107     private static final long MAX_AGE_DEFAULT_PREFERENCES = 60L * 60L * 24L * 50L; // 50 days (in seconds)
     108    private static final long MAX_AGE_DEFAULT_PREFERENCES = TimeUnit.DAYS.toSeconds(50);
    108109
    109110    /**
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java

    r10877 r11288  
    4747public abstract class JCSCachedTileLoaderJob<K, V extends CacheEntry> implements ICachedLoaderJob<K> {
    4848    private static final Logger LOG = FeatureAdapter.getLogger(JCSCachedTileLoaderJob.class.getCanonicalName());
    49     protected static final long DEFAULT_EXPIRE_TIME = 1000L * 60 * 60 * 24 * 7; // 7 days
     49    protected static final long DEFAULT_EXPIRE_TIME = TimeUnit.DAYS.toMillis(7);
    5050    // Limit for the max-age value send by the server.
    51     protected static final long EXPIRE_TIME_SERVER_LIMIT = 1000L * 60 * 60 * 24 * 28; // 4 weeks
     51    protected static final long EXPIRE_TIME_SERVER_LIMIT = TimeUnit.DAYS.toMillis(28);
    5252    // Absolute expire time limit. Cached tiles that are older will not be used,
    5353    // even if the refresh from the server fails.
    54     protected static final long ABSOLUTE_EXPIRE_TIME_LIMIT = 1000L * 60 * 60 * 24 * 365; // 1 year
     54    protected static final long ABSOLUTE_EXPIRE_TIME_LIMIT = TimeUnit.DAYS.toMillis(365);
    5555
    5656    /**
     
    432432                    for (String token: str.split(",")) {
    433433                        if (token.startsWith("max-age=")) {
    434                             lng = Long.parseLong(token.substring(8)) * 1000 +
    435                                     System.currentTimeMillis();
     434                            lng = TimeUnit.SECONDS.toMillis(Long.parseLong(token.substring(8))) + System.currentTimeMillis();
    436435                        }
    437436                    }
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r11095 r11288  
    66import java.util.Collections;
    77import java.util.Date;
     8import java.util.DoubleSummaryStatistics;
    89import java.util.HashSet;
    910import java.util.Iterator;
     
    1819import org.openstreetmap.josm.data.DataSource;
    1920import org.openstreetmap.josm.data.coor.EastNorth;
    20 import org.openstreetmap.josm.tools.Utils;
    2121
    2222/**
     
    193193     */
    194194    public static Date[] getMinMaxTimeForTrack(GpxTrack trk) {
    195         WayPoint earliest = null, latest = null;
    196 
    197         for (GpxTrackSegment seg : trk.getSegments()) {
    198             for (WayPoint pnt : seg.getWayPoints()) {
    199                 if (latest == null) {
    200                     latest = earliest = pnt;
    201                 } else {
    202                     if (pnt.compareTo(earliest) < 0) {
    203                         earliest = pnt;
    204                     } else if (pnt.compareTo(latest) > 0) {
    205                         latest = pnt;
    206                     }
    207                 }
    208             }
    209         }
    210         if (earliest == null || latest == null) return null;
    211         return new Date[]{earliest.getTime(), latest.getTime()};
     195        final DoubleSummaryStatistics statistics = trk.getSegments().stream()
     196                .flatMap(seg -> seg.getWayPoints().stream())
     197                .mapToDouble(pnt -> pnt.time)
     198                .summaryStatistics();
     199        return statistics.getCount() == 0
     200                ? null
     201                : new Date[]{new Date((long) (statistics.getMin() * 1000)), new Date((long) (statistics.getMax() * 1000))};
    212202    }
    213203
     
    220210    */
    221211    public Date[] getMinMaxTimeForAllTracks() {
    222         double min = 1e100;
    223         double max = -1e100;
    224         double now = System.currentTimeMillis()/1000.0;
    225         for (GpxTrack trk: tracks) {
    226             for (GpxTrackSegment seg : trk.getSegments()) {
    227                 for (WayPoint pnt : seg.getWayPoints()) {
    228                     double t = pnt.time;
    229                     if (t > 0 && t <= now) {
    230                         if (t > max) max = t;
    231                         if (t < min) min = t;
    232                     }
    233                 }
    234             }
    235         }
    236         if (Utils.equalsEpsilon(min, 1e100) || Utils.equalsEpsilon(max, -1e100)) return new Date[0];
    237         return new Date[]{new Date((long) (min * 1000)), new Date((long) (max * 1000))};
     212        double now = System.currentTimeMillis() / 1000.0;
     213        final DoubleSummaryStatistics statistics = tracks.stream()
     214                .flatMap(trk -> trk.getSegments().stream())
     215                .flatMap(seg -> seg.getWayPoints().stream())
     216                .mapToDouble(pnt -> pnt.time)
     217                .filter(t -> t > 0 && t <= now)
     218                .summaryStatistics();
     219        return statistics.getCount() == 0
     220                ? new Date[0]
     221                : new Date[]{new Date((long) (statistics.getMin() * 1000)), new Date((long) (statistics.getMax() * 1000))};
    238222    }
    239223
  • trunk/src/org/openstreetmap/josm/data/imagery/CachedAttributionBingAerialTileSource.java

    r10608 r11288  
    77import java.util.List;
    88import java.util.concurrent.Callable;
     9import java.util.concurrent.TimeUnit;
    910
    1011import org.openstreetmap.gui.jmapviewer.tilesources.BingAerialTileSource;
     
    7576                } catch (IOException ex) {
    7677                    Main.warn(ex, "Could not connect to Bing API. Will retry in " + waitTimeSec + " seconds.");
    77                     Thread.sleep(waitTimeSec * 1000L);
     78                    Thread.sleep(TimeUnit.SECONDS.toMillis(waitTimeSec));
    7879                    waitTimeSec *= 2;
    7980                }
  • trunk/src/org/openstreetmap/josm/data/imagery/CachedTileLoaderFactory.java

    r11188 r11288  
    66import java.util.Map;
    77import java.util.concurrent.ConcurrentHashMap;
     8import java.util.concurrent.TimeUnit;
    89
    910import org.apache.commons.jcs.access.behavior.ICacheAccess;
     
    7071
    7172        return getLoader(listener, cache,
    72                 Main.pref.getInteger("socket.timeout.connect", 15) * 1000,
    73                 Main.pref.getInteger("socket.timeout.read", 30) * 1000,
     73                (int) TimeUnit.SECONDS.toMillis(Main.pref.getInteger("socket.timeout.connect", 15)),
     74                (int) TimeUnit.SECONDS.toMillis(Main.pref.getInteger("socket.timeout.read", 30)),
    7475                headers);
    7576    }
  • trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java

    r10723 r11288  
    1515import java.util.concurrent.ConcurrentMap;
    1616import java.util.concurrent.ThreadPoolExecutor;
     17import java.util.concurrent.TimeUnit;
    1718import java.util.logging.Level;
    1819import java.util.logging.Logger;
     
    4243public class TMSCachedTileLoaderJob extends JCSCachedTileLoaderJob<String, BufferedImageCacheEntry> implements TileJob, ICachedLoaderListener {
    4344    private static final Logger LOG = FeatureAdapter.getLogger(TMSCachedTileLoaderJob.class.getCanonicalName());
    44     private static final LongProperty MAXIMUM_EXPIRES = new LongProperty("imagery.generic.maximum_expires",
    45             30 /*days*/ * 24 /*hours*/ * 60 /*minutes*/ * 60 /*seconds*/ *1000L /*milliseconds*/);
    46     private static final LongProperty MINIMUM_EXPIRES = new LongProperty("imagery.generic.minimum_expires",
    47             1 /*hour*/ * 60 /*minutes*/ * 60 /*seconds*/ *1000L /*milliseconds*/);
     45    private static final LongProperty MAXIMUM_EXPIRES = new LongProperty("imagery.generic.maximum_expires", TimeUnit.DAYS.toMillis(30));
     46    private static final LongProperty MINIMUM_EXPIRES = new LongProperty("imagery.generic.minimum_expires", TimeUnit.HOURS.toMillis(1));
    4847    private final Tile tile;
    4948    private volatile URL url;
  • trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java

    r10600 r11288  
    1414import java.util.Objects;
    1515import java.util.Set;
     16import java.util.concurrent.TimeUnit;
    1617import java.util.concurrent.atomic.AtomicLong;
    1718
     
    249250    @Override
    250251    public void setTimestamp(Date timestamp) {
    251         this.timestamp = (int) (timestamp.getTime() / 1000);
     252        this.timestamp = (int) TimeUnit.MILLISECONDS.toSeconds(timestamp.getTime());
    252253    }
    253254
     
    259260    @Override
    260261    public Date getTimestamp() {
    261         return new Date(timestamp * 1000L);
     262        return new Date(TimeUnit.SECONDS.toMillis(timestamp));
    262263    }
    263264
  • trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java

    r10611 r11288  
    1616import java.util.LinkedList;
    1717import java.util.List;
     18import java.util.concurrent.TimeUnit;
    1819
    1920import javax.swing.Action;
     
    149150        hcbUploadComment.addCurrentItemToHistory();
    150151        Main.pref.putCollection(HISTORY_KEY, hcbUploadComment.getHistory());
    151         Main.pref.putInteger(HISTORY_LAST_USED_KEY, (int) (System.currentTimeMillis() / 1000));
     152        Main.pref.putInteger(HISTORY_LAST_USED_KEY, (int) (TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())));
    152153        // store the history of sources
    153154        hcbUploadSource.addCurrentItemToHistory();
  • trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java

    r10791 r11288  
    2525import java.util.Map;
    2626import java.util.Map.Entry;
     27import java.util.concurrent.TimeUnit;
    2728
    2829import javax.swing.AbstractAction;
     
    640641        Collection<String> history = Main.pref.getCollection(historyKey, def);
    641642        int age = (int) (System.currentTimeMillis() / 1000 - Main.pref.getInteger(BasicUploadSettingsPanel.HISTORY_LAST_USED_KEY, 0));
    642         if (age < Main.pref.getInteger(BasicUploadSettingsPanel.HISTORY_MAX_AGE_KEY, 4 * 3600 * 1000) && history != null && !history.isEmpty()) {
     643        if (age < Main.pref.getLong(BasicUploadSettingsPanel.HISTORY_MAX_AGE_KEY, TimeUnit.HOURS.toMillis(4)) && history != null && !history.isEmpty()) {
    643644            return history.iterator().next();
    644645        } else {
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r11017 r11288  
    3838import java.util.Objects;
    3939import java.util.TimeZone;
     40import java.util.concurrent.TimeUnit;
    4041import java.util.zip.GZIPInputStream;
    4142
     
    408409                TimeZone tz = TimeZone.getTimeZone(tzStr);
    409410
    410                 String tzDesc = new StringBuilder(tzStr).append(" (")
    411                 .append(new Timezone(tz.getRawOffset() / 3600000.0).formatTimezone())
    412                 .append(')').toString();
     411                String tzDesc = tzStr + " (" +
     412                        new Timezone(((double) tz.getRawOffset()) / TimeUnit.HOURS.toMillis(1)).formatTimezone() +
     413                        ')';
    413414                vtTimezones.add(tzDesc);
    414415            }
     
    426427            }
    427428
    428             cbTimezones.setSelectedItem(new StringBuilder(defaultTz.getID()).append(" (")
    429                     .append(new Timezone(defaultTz.getRawOffset() / 3600000.0).formatTimezone())
    430                     .append(')').toString());
     429            cbTimezones.setSelectedItem(defaultTz.getID() + " (" +
     430                    new Timezone(((double) defaultTz.getRawOffset()) / TimeUnit.HOURS.toMillis(1)).formatTimezone() +
     431                    ')');
    431432
    432433            gc.gridx = 1;
     
    815816                return tr("No gpx selected");
    816817
    817             final long offsetMs = ((long) (timezone.getHours() * 3600 * 1000)) + delta.getMilliseconds(); // in milliseconds
     818            final long offsetMs = ((long) (timezone.getHours() * TimeUnit.HOURS.toMillis(1))) + delta.getMilliseconds(); // in milliseconds
    818819            lastNumMatched = matchGpxTrack(dateImgLst, selGpx.data, offsetMs);
    819820
     
    846847
    847848            final Offset offset = Offset.milliseconds(
    848                     delta.getMilliseconds() + Math.round(timezone.getHours() * 60 * 60 * 1000));
     849                    delta.getMilliseconds() + Math.round(timezone.getHours() * TimeUnit.HOURS.toMillis(1)));
    849850            final int dayOffset = offset.getDayOffset();
    850851            final Pair<Timezone, Offset> timezoneOffsetPair = offset.withoutDayOffset().splitOutTimezone();
     
    897898
    898899                    delta = Offset.milliseconds(100L * sldSeconds.getValue()
    899                             + 1000L * 60 * sldMinutes.getValue()
    900                             + 1000L * 60 * 60 * 24 * dayOffset);
     900                            + TimeUnit.MINUTES.toMillis(sldMinutes.getValue())
     901                            + TimeUnit.DAYS.toMillis(dayOffset));
    901902
    902903                    tfTimezone.getDocument().removeDocumentListener(statusBarUpdater);
     
    11461147        // Time between the track point and the previous one, 5 sec if first point, i.e. photos take
    11471148        // 5 sec before the first track point can be assumed to be take at the starting position
    1148         long interval = prevWpTime > 0 ? Math.abs(curWpTime - prevWpTime) : 5*1000;
     1149        long interval = prevWpTime > 0 ? Math.abs(curWpTime - prevWpTime) : TimeUnit.SECONDS.toMillis(5);
    11491150        int ret = 0;
    11501151
     
    14321433
    14331434        int getDayOffset() {
    1434             final double diffInH = getMilliseconds() / 1000. / 60 / 60; // hours
    1435 
    14361435            // Find day difference
    1437             return (int) Math.round(diffInH / 24);
     1436            return (int) Math.round(((double) getMilliseconds()) / TimeUnit.DAYS.toMillis(1));
    14381437        }
    14391438
    14401439        Offset withoutDayOffset() {
    1441             return milliseconds(getMilliseconds() - getDayOffset() * 24L * 60L * 60L * 1000L);
     1440            return milliseconds(getMilliseconds() - TimeUnit.DAYS.toMillis(getDayOffset()));
    14421441        }
    14431442
    14441443        Pair<Timezone, Offset> splitOutTimezone() {
    14451444            // In hours
    1446             double tz = withoutDayOffset().getSeconds() / 3600.0;
     1445            final double tz = ((double) withoutDayOffset().getSeconds()) / TimeUnit.HOURS.toSeconds(1);
    14471446
    14481447            // Due to imprecise clocks we might get a "+3:28" timezone, which should obviously be 3:30 with
    14491448            // -2 minutes offset. This determines the real timezone and finds offset.
    14501449            final double timezone = (double) Math.round(tz * 2) / 2; // hours, rounded to one decimal place
    1451             final long delta = Math.round(getMilliseconds() - timezone * 60 * 60 * 1000); // milliseconds
     1450            final long delta = Math.round(getMilliseconds() - timezone * TimeUnit.HOURS.toMillis(1));
    14521451            return Pair.create(new Timezone(timezone), Offset.milliseconds(delta));
    14531452        }
  • trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java

    r10627 r11288  
    99import java.io.IOException;
    1010import java.nio.charset.StandardCharsets;
     11import java.util.concurrent.TimeUnit;
    1112
    1213import org.openstreetmap.josm.Main;
     
    2526    public static final int INTERVAL_ALWAYS = -1;
    2627    /** Update interval meaning an update is needed each hour */
    27     public static final int INTERVAL_HOURLY = 60*60;
     28    public static final int INTERVAL_HOURLY = (int) TimeUnit.HOURS.toSeconds(1);
    2829    /** Update interval meaning an update is needed each day */
    29     public static final int INTERVAL_DAILY = INTERVAL_HOURLY * 24;
     30    public static final int INTERVAL_DAILY = (int) TimeUnit.DAYS.toSeconds(1);
    3031    /** Update interval meaning an update is needed each week */
    31     public static final int INTERVAL_WEEKLY = INTERVAL_DAILY * 7;
     32    public static final int INTERVAL_WEEKLY = (int) TimeUnit.DAYS.toSeconds(7);
    3233    /** Update interval meaning an update is needed each month */
    33     public static final int INTERVAL_MONTHLY = INTERVAL_WEEKLY * 4;
     34    public static final int INTERVAL_MONTHLY = (int) TimeUnit.DAYS.toSeconds(28);
    3435    /** Update interval meaning an update is never needed */
    3536    public static final int INTERVAL_NEVER = Integer.MAX_VALUE;
     
    8889            return false;
    8990        }
    90         return Main.pref.getInteger("cache." + ident, 0) + updateInterval < System.currentTimeMillis()/1000
     91        return Main.pref.getInteger("cache." + ident, 0) + updateInterval < TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())
    9192                || !isCacheValid();
    9293    }
     
    136137        this.data = updateData();
    137138        saveToDisk();
    138         Main.pref.putInteger("cache." + ident, (int) (System.currentTimeMillis()/1000));
     139        Main.pref.putInteger("cache." + ident, (int) (TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())));
    139140        return data;
    140141    }
  • trunk/src/org/openstreetmap/josm/io/CachedFile.java

    r11195 r11288  
    2424import java.util.Map;
    2525import java.util.concurrent.ConcurrentHashMap;
     26import java.util.concurrent.TimeUnit;
    2627import java.util.zip.ZipEntry;
    2728import java.util.zip.ZipFile;
     
    7677
    7778    public static final long DEFAULT_MAXTIME = -1L;
    78     public static final long DAYS = 24L*60L*60L; // factor to get caching time in days
     79    public static final long DAYS = TimeUnit.DAYS.toSeconds(1); // factor to get caching time in days
    7980
    8081    private final Map<String, String> httpHeaders = new ConcurrentHashMap<>();
     
    417418        String urlStr = url.toExternalForm();
    418419        long age = 0L;
    419         long lMaxAge = maxAge;
     420        long maxAgeMillis = maxAge;
    420421        Long ifModifiedSince = null;
    421422        File localFile = null;
     
    436437                        || maxAge <= 0 // arbitrary value <= 0 is deprecated
    437438                ) {
    438                     lMaxAge = Main.pref.getInteger("mirror.maxtime", 7*24*60*60); // one week
     439                    maxAgeMillis = TimeUnit.SECONDS.toMillis(Main.pref.getLong("mirror.maxtime", TimeUnit.DAYS.toSeconds(7)));
    439440                }
    440441                age = System.currentTimeMillis() - Long.parseLong(localPathEntry.get(0));
    441                 if (offline || age < lMaxAge*1000) {
     442                if (offline || age < maxAgeMillis) {
    442443                    return localFile;
    443444                }
     
    498499            }
    499500        } catch (IOException e) {
    500             if (age >= lMaxAge*1000 && age < lMaxAge*1000*2) {
     501            if (age >= maxAgeMillis && age < maxAgeMillis*2) {
    501502                Main.warn(tr("Failed to load {0}, use cached file and retry next time: {1}", urlStr, e));
    502503                return localFile;
  • trunk/src/org/openstreetmap/josm/io/MessageNotifier.java

    r10627 r11288  
    9393            Main.info(tr("{0} not available (offline mode)", tr("Message notifier")));
    9494        } else if (!isRunning() && interval > 0 && isUserEnoughIdentified()) {
    95             task = EXECUTOR.scheduleAtFixedRate(WORKER, 0, interval * 60L, TimeUnit.SECONDS);
     95            task = EXECUTOR.scheduleAtFixedRate(WORKER, 0, TimeUnit.MINUTES.toSeconds(interval), TimeUnit.SECONDS);
    9696            Main.info("Message notifier active (checks every "+interval+" minute"+(interval > 1 ? "s" : "")+')');
    9797        }
  • trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java

    r10217 r11288  
    1111import java.util.LinkedList;
    1212import java.util.List;
     13import java.util.concurrent.TimeUnit;
    1314
    1415import org.openstreetmap.josm.data.osm.Changeset;
     
    6465    private boolean canceled;
    6566
    66     private static final int MSECS_PER_SECOND = 1000;
    67     private static final int SECONDS_PER_MINUTE = 60;
    68     private static final int MSECS_PER_MINUTE = MSECS_PER_SECOND * SECONDS_PER_MINUTE;
    69 
    7067    private long uploadStartTime;
    7168
     
    7976        double uploadsLeft = (double) listSize - progress;
    8077        long msLeft = (long) (uploadsLeft / uploadsPerMs);
    81         long minutesLeft = msLeft / MSECS_PER_MINUTE;
    82         long secondsLeft = (msLeft / MSECS_PER_SECOND) % SECONDS_PER_MINUTE;
     78        long minutesLeft = msLeft / TimeUnit.MINUTES.toMillis(1);
     79        long secondsLeft = (msLeft / TimeUnit.SECONDS.toMillis(1)) % TimeUnit.MINUTES.toSeconds(1);
    8380        StringBuilder timeLeftStr = new StringBuilder().append(minutesLeft).append(':');
    8481        if (secondsLeft < 10) {
  • trunk/src/org/openstreetmap/josm/io/OverpassDownloadReader.java

    r11048 r11288  
    99import java.util.List;
    1010import java.util.NoSuchElementException;
     11import java.util.concurrent.TimeUnit;
    1112import java.util.regex.Matcher;
    1213import java.util.regex.Pattern;
     
    132133        final int timeout;
    133134        if (timeoutMatcher.find()) {
    134             timeout = 1000 * Integer.parseInt(timeoutMatcher.group(1));
     135            timeout = (int) TimeUnit.SECONDS.toMillis(Integer.parseInt(timeoutMatcher.group(1)));
    135136        } else {
    136             timeout = 180_000;
     137            timeout = (int) TimeUnit.MINUTES.toMillis(3);
    137138        }
    138139        request.setConnectTimeout(timeout);
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r10987 r11288  
    3737import java.util.concurrent.ExecutionException;
    3838import java.util.concurrent.FutureTask;
     39import java.util.concurrent.TimeUnit;
    3940import java.util.jar.JarFile;
    4041import java.util.stream.Collectors;
     
    384385            long last = Main.pref.getLong("pluginmanager.lastupdate", 0);
    385386            Integer maxTime = Main.pref.getInteger("pluginmanager.time-based-update.interval", DEFAULT_TIME_BASED_UPDATE_INTERVAL);
    386             long d = (tim - last) / (24 * 60 * 60 * 1000L);
     387            long d = TimeUnit.MILLISECONDS.toDays(tim - last);
    387388            if ((last <= 0) || (maxTime <= 0)) {
    388389                Main.pref.put("pluginmanager.lastupdate", Long.toString(tim));
  • trunk/src/org/openstreetmap/josm/tools/ExifReader.java

    r10378 r11288  
    66import java.io.IOException;
    77import java.util.Date;
     8import java.util.concurrent.TimeUnit;
    89
    910import org.openstreetmap.josm.Main;
     
    7071                if (subSeconds != null) {
    7172                    try {
    72                         date.setTime(date.getTime() + (long) (1000L * Double.parseDouble("0." + subSeconds)));
     73                        date.setTime(date.getTime() + (long) (TimeUnit.SECONDS.toMillis(1) * Double.parseDouble("0." + subSeconds)));
    7374                    } catch (NumberFormatException e) {
    7475                        Main.warn("Failed parsing sub seconds from [{0}]", subSeconds);
  • trunk/src/org/openstreetmap/josm/tools/HttpClient.java

    r11277 r11288  
    2121import java.util.Scanner;
    2222import java.util.TreeMap;
     23import java.util.concurrent.TimeUnit;
    2324import java.util.regex.Matcher;
    2425import java.util.regex.Pattern;
     
    4344    private URL url;
    4445    private final String requestMethod;
    45     private int connectTimeout = Main.pref.getInteger("socket.timeout.connect", 15) * 1000;
    46     private int readTimeout = Main.pref.getInteger("socket.timeout.read", 30) * 1000;
     46    private int connectTimeout = (int) TimeUnit.SECONDS.toMillis(Main.pref.getInteger("socket.timeout.connect", 15));
     47    private int readTimeout = (int) TimeUnit.SECONDS.toMillis(Main.pref.getInteger("socket.timeout.read", 30));
    4748    private byte[] requestBody;
    4849    private long ifModifiedSince;
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r11100 r11288  
    4747import java.util.concurrent.ForkJoinWorkerThread;
    4848import java.util.concurrent.ThreadFactory;
     49import java.util.concurrent.TimeUnit;
    4950import java.util.concurrent.atomic.AtomicLong;
    5051import java.util.function.Function;
     
    7980    public static final Pattern WHITE_SPACES_PATTERN = Pattern.compile("\\s+");
    8081
    81     private static final int MILLIS_OF_SECOND = 1000;
    82     private static final int MILLIS_OF_MINUTE = 60_000;
    83     private static final int MILLIS_OF_HOUR = 3_600_000;
    84     private static final int MILLIS_OF_DAY = 86_400_000;
     82    private static final long MILLIS_OF_SECOND = TimeUnit.SECONDS.toMillis(1);
     83    private static final long MILLIS_OF_MINUTE = TimeUnit.MINUTES.toMillis(1);
     84    private static final long MILLIS_OF_HOUR = TimeUnit.HOURS.toMillis(1);
     85    private static final long MILLIS_OF_DAY = TimeUnit.DAYS.toMillis(1);
    8586
    8687    /**
  • trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java

    r11048 r11288  
    1313import java.util.Locale;
    1414import java.util.TimeZone;
     15import java.util.concurrent.TimeUnit;
    1516
    1617import javax.xml.datatype.DatatypeConfigurationException;
     
    145146     */
    146147    public static synchronized String fromTimestamp(int timestamp) {
    147         final ZonedDateTime temporal = Instant.ofEpochMilli(timestamp * 1000L).atZone(ZoneOffset.UTC);
     148        final ZonedDateTime temporal = Instant.ofEpochMilli(TimeUnit.SECONDS.toMillis(timestamp)).atZone(ZoneOffset.UTC);
    148149        return DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(temporal);
    149150    }
Note: See TracChangeset for help on using the changeset viewer.