Changeset 11288 in josm for trunk/src/org
- Timestamp:
- 2016-11-20T17:33:33+01:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r10601 r11288 15 15 import java.util.HashSet; 16 16 import java.util.List; 17 import java.util.concurrent.TimeUnit; 17 18 18 19 import javax.swing.JOptionPane; … … 312 313 313 314 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))) { 315 317 lastZoomTime = -1; 316 318 } -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r11192 r11288 1204 1204 @Override 1205 1205 protected Long getNumber(OsmPrimitive osm) { 1206 return osm.get RawTimestamp() * 1000L;1206 return osm.getTimestamp().getTime(); 1207 1207 } 1208 1208 -
trunk/src/org/openstreetmap/josm/data/AutosaveTask.java
r10938 r11288 26 26 import java.util.concurrent.ExecutionException; 27 27 import java.util.concurrent.Future; 28 import java.util.concurrent.TimeUnit; 28 29 import java.util.regex.Pattern; 29 30 … … 75 76 public static final IntegerProperty PROP_FILES_PER_LAYER = new IntegerProperty("autosave.filesPerLayer", 1); 76 77 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)); 78 79 public static final IntegerProperty PROP_INDEX_LIMIT = new IntegerProperty("autosave.index-limit", 1000); 79 80 /** Defines if a notification should be displayed after each autosave */ … … 131 132 } 132 133 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())); 134 135 Main.getLayerManager().addLayerChangeListener(this, true); 135 136 } -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r11162 r11288 36 36 import java.util.SortedMap; 37 37 import java.util.TreeMap; 38 import java.util.concurrent.TimeUnit; 38 39 import java.util.function.Predicate; 39 40 import java.util.regex.Matcher; … … 105 106 }; 106 107 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); 108 109 109 110 /** -
trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
r10877 r11288 47 47 public abstract class JCSCachedTileLoaderJob<K, V extends CacheEntry> implements ICachedLoaderJob<K> { 48 48 private static final Logger LOG = FeatureAdapter.getLogger(JCSCachedTileLoaderJob.class.getCanonicalName()); 49 protected static final long DEFAULT_EXPIRE_TIME = 1000L * 60 * 60 * 24 * 7; // 7 days49 protected static final long DEFAULT_EXPIRE_TIME = TimeUnit.DAYS.toMillis(7); 50 50 // 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 weeks51 protected static final long EXPIRE_TIME_SERVER_LIMIT = TimeUnit.DAYS.toMillis(28); 52 52 // Absolute expire time limit. Cached tiles that are older will not be used, 53 53 // even if the refresh from the server fails. 54 protected static final long ABSOLUTE_EXPIRE_TIME_LIMIT = 1000L * 60 * 60 * 24 * 365; // 1 year54 protected static final long ABSOLUTE_EXPIRE_TIME_LIMIT = TimeUnit.DAYS.toMillis(365); 55 55 56 56 /** … … 432 432 for (String token: str.split(",")) { 433 433 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(); 436 435 } 437 436 } -
trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
r11095 r11288 6 6 import java.util.Collections; 7 7 import java.util.Date; 8 import java.util.DoubleSummaryStatistics; 8 9 import java.util.HashSet; 9 10 import java.util.Iterator; … … 18 19 import org.openstreetmap.josm.data.DataSource; 19 20 import org.openstreetmap.josm.data.coor.EastNorth; 20 import org.openstreetmap.josm.tools.Utils;21 21 22 22 /** … … 193 193 */ 194 194 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))}; 212 202 } 213 203 … … 220 210 */ 221 211 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))}; 238 222 } 239 223 -
trunk/src/org/openstreetmap/josm/data/imagery/CachedAttributionBingAerialTileSource.java
r10608 r11288 7 7 import java.util.List; 8 8 import java.util.concurrent.Callable; 9 import java.util.concurrent.TimeUnit; 9 10 10 11 import org.openstreetmap.gui.jmapviewer.tilesources.BingAerialTileSource; … … 75 76 } catch (IOException ex) { 76 77 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)); 78 79 waitTimeSec *= 2; 79 80 } -
trunk/src/org/openstreetmap/josm/data/imagery/CachedTileLoaderFactory.java
r11188 r11288 6 6 import java.util.Map; 7 7 import java.util.concurrent.ConcurrentHashMap; 8 import java.util.concurrent.TimeUnit; 8 9 9 10 import org.apache.commons.jcs.access.behavior.ICacheAccess; … … 70 71 71 72 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)), 74 75 headers); 75 76 } -
trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
r10723 r11288 15 15 import java.util.concurrent.ConcurrentMap; 16 16 import java.util.concurrent.ThreadPoolExecutor; 17 import java.util.concurrent.TimeUnit; 17 18 import java.util.logging.Level; 18 19 import java.util.logging.Logger; … … 42 43 public class TMSCachedTileLoaderJob extends JCSCachedTileLoaderJob<String, BufferedImageCacheEntry> implements TileJob, ICachedLoaderListener { 43 44 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)); 48 47 private final Tile tile; 49 48 private volatile URL url; -
trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
r10600 r11288 14 14 import java.util.Objects; 15 15 import java.util.Set; 16 import java.util.concurrent.TimeUnit; 16 17 import java.util.concurrent.atomic.AtomicLong; 17 18 … … 249 250 @Override 250 251 public void setTimestamp(Date timestamp) { 251 this.timestamp = (int) (timestamp.getTime() / 1000);252 this.timestamp = (int) TimeUnit.MILLISECONDS.toSeconds(timestamp.getTime()); 252 253 } 253 254 … … 259 260 @Override 260 261 public Date getTimestamp() { 261 return new Date( timestamp * 1000L);262 return new Date(TimeUnit.SECONDS.toMillis(timestamp)); 262 263 } 263 264 -
trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java
r10611 r11288 16 16 import java.util.LinkedList; 17 17 import java.util.List; 18 import java.util.concurrent.TimeUnit; 18 19 19 20 import javax.swing.Action; … … 149 150 hcbUploadComment.addCurrentItemToHistory(); 150 151 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()))); 152 153 // store the history of sources 153 154 hcbUploadSource.addCurrentItemToHistory(); -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r10791 r11288 25 25 import java.util.Map; 26 26 import java.util.Map.Entry; 27 import java.util.concurrent.TimeUnit; 27 28 28 29 import javax.swing.AbstractAction; … … 640 641 Collection<String> history = Main.pref.getCollection(historyKey, def); 641 642 int age = (int) (System.currentTimeMillis() / 1000 - Main.pref.getInteger(BasicUploadSettingsPanel.HISTORY_LAST_USED_KEY, 0)); 642 if (age < Main.pref.get Integer(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()) { 643 644 return history.iterator().next(); 644 645 } else { -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
r11017 r11288 38 38 import java.util.Objects; 39 39 import java.util.TimeZone; 40 import java.util.concurrent.TimeUnit; 40 41 import java.util.zip.GZIPInputStream; 41 42 … … 408 409 TimeZone tz = TimeZone.getTimeZone(tzStr); 409 410 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 ')'; 413 414 vtTimezones.add(tzDesc); 414 415 } … … 426 427 } 427 428 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 ')'); 431 432 432 433 gc.gridx = 1; … … 815 816 return tr("No gpx selected"); 816 817 817 final long offsetMs = ((long) (timezone.getHours() * 3600 * 1000)) + delta.getMilliseconds(); // in milliseconds818 final long offsetMs = ((long) (timezone.getHours() * TimeUnit.HOURS.toMillis(1))) + delta.getMilliseconds(); // in milliseconds 818 819 lastNumMatched = matchGpxTrack(dateImgLst, selGpx.data, offsetMs); 819 820 … … 846 847 847 848 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))); 849 850 final int dayOffset = offset.getDayOffset(); 850 851 final Pair<Timezone, Offset> timezoneOffsetPair = offset.withoutDayOffset().splitOutTimezone(); … … 897 898 898 899 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)); 901 902 902 903 tfTimezone.getDocument().removeDocumentListener(statusBarUpdater); … … 1146 1147 // Time between the track point and the previous one, 5 sec if first point, i.e. photos take 1147 1148 // 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); 1149 1150 int ret = 0; 1150 1151 … … 1432 1433 1433 1434 int getDayOffset() { 1434 final double diffInH = getMilliseconds() / 1000. / 60 / 60; // hours1435 1436 1435 // Find day difference 1437 return (int) Math.round( diffInH / 24);1436 return (int) Math.round(((double) getMilliseconds()) / TimeUnit.DAYS.toMillis(1)); 1438 1437 } 1439 1438 1440 1439 Offset withoutDayOffset() { 1441 return milliseconds(getMilliseconds() - getDayOffset() * 24L * 60L * 60L * 1000L);1440 return milliseconds(getMilliseconds() - TimeUnit.DAYS.toMillis(getDayOffset())); 1442 1441 } 1443 1442 1444 1443 Pair<Timezone, Offset> splitOutTimezone() { 1445 1444 // In hours 1446 double tz = withoutDayOffset().getSeconds() / 3600.0;1445 final double tz = ((double) withoutDayOffset().getSeconds()) / TimeUnit.HOURS.toSeconds(1); 1447 1446 1448 1447 // Due to imprecise clocks we might get a "+3:28" timezone, which should obviously be 3:30 with 1449 1448 // -2 minutes offset. This determines the real timezone and finds offset. 1450 1449 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); // milliseconds1450 final long delta = Math.round(getMilliseconds() - timezone * TimeUnit.HOURS.toMillis(1)); 1452 1451 return Pair.create(new Timezone(timezone), Offset.milliseconds(delta)); 1453 1452 } -
trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java
r10627 r11288 9 9 import java.io.IOException; 10 10 import java.nio.charset.StandardCharsets; 11 import java.util.concurrent.TimeUnit; 11 12 12 13 import org.openstreetmap.josm.Main; … … 25 26 public static final int INTERVAL_ALWAYS = -1; 26 27 /** 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); 28 29 /** 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); 30 31 /** 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); 32 33 /** 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); 34 35 /** Update interval meaning an update is never needed */ 35 36 public static final int INTERVAL_NEVER = Integer.MAX_VALUE; … … 88 89 return false; 89 90 } 90 return Main.pref.getInteger("cache." + ident, 0) + updateInterval < System.currentTimeMillis()/100091 return Main.pref.getInteger("cache." + ident, 0) + updateInterval < TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()) 91 92 || !isCacheValid(); 92 93 } … … 136 137 this.data = updateData(); 137 138 saveToDisk(); 138 Main.pref.putInteger("cache." + ident, (int) ( System.currentTimeMillis()/1000));139 Main.pref.putInteger("cache." + ident, (int) (TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()))); 139 140 return data; 140 141 } -
trunk/src/org/openstreetmap/josm/io/CachedFile.java
r11195 r11288 24 24 import java.util.Map; 25 25 import java.util.concurrent.ConcurrentHashMap; 26 import java.util.concurrent.TimeUnit; 26 27 import java.util.zip.ZipEntry; 27 28 import java.util.zip.ZipFile; … … 76 77 77 78 public static final long DEFAULT_MAXTIME = -1L; 78 public static final long DAYS = 24L*60L*60L; // factor to get caching time in days79 public static final long DAYS = TimeUnit.DAYS.toSeconds(1); // factor to get caching time in days 79 80 80 81 private final Map<String, String> httpHeaders = new ConcurrentHashMap<>(); … … 417 418 String urlStr = url.toExternalForm(); 418 419 long age = 0L; 419 long lMaxAge= maxAge;420 long maxAgeMillis = maxAge; 420 421 Long ifModifiedSince = null; 421 422 File localFile = null; … … 436 437 || maxAge <= 0 // arbitrary value <= 0 is deprecated 437 438 ) { 438 lMaxAge = Main.pref.getInteger("mirror.maxtime", 7*24*60*60); // one week439 maxAgeMillis = TimeUnit.SECONDS.toMillis(Main.pref.getLong("mirror.maxtime", TimeUnit.DAYS.toSeconds(7))); 439 440 } 440 441 age = System.currentTimeMillis() - Long.parseLong(localPathEntry.get(0)); 441 if (offline || age < lMaxAge*1000) {442 if (offline || age < maxAgeMillis) { 442 443 return localFile; 443 444 } … … 498 499 } 499 500 } catch (IOException e) { 500 if (age >= lMaxAge*1000 && age < lMaxAge*1000*2) {501 if (age >= maxAgeMillis && age < maxAgeMillis*2) { 501 502 Main.warn(tr("Failed to load {0}, use cached file and retry next time: {1}", urlStr, e)); 502 503 return localFile; -
trunk/src/org/openstreetmap/josm/io/MessageNotifier.java
r10627 r11288 93 93 Main.info(tr("{0} not available (offline mode)", tr("Message notifier"))); 94 94 } 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); 96 96 Main.info("Message notifier active (checks every "+interval+" minute"+(interval > 1 ? "s" : "")+')'); 97 97 } -
trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java
r10217 r11288 11 11 import java.util.LinkedList; 12 12 import java.util.List; 13 import java.util.concurrent.TimeUnit; 13 14 14 15 import org.openstreetmap.josm.data.osm.Changeset; … … 64 65 private boolean canceled; 65 66 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 70 67 private long uploadStartTime; 71 68 … … 79 76 double uploadsLeft = (double) listSize - progress; 80 77 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); 83 80 StringBuilder timeLeftStr = new StringBuilder().append(minutesLeft).append(':'); 84 81 if (secondsLeft < 10) { -
trunk/src/org/openstreetmap/josm/io/OverpassDownloadReader.java
r11048 r11288 9 9 import java.util.List; 10 10 import java.util.NoSuchElementException; 11 import java.util.concurrent.TimeUnit; 11 12 import java.util.regex.Matcher; 12 13 import java.util.regex.Pattern; … … 132 133 final int timeout; 133 134 if (timeoutMatcher.find()) { 134 timeout = 1000 * Integer.parseInt(timeoutMatcher.group(1));135 timeout = (int) TimeUnit.SECONDS.toMillis(Integer.parseInt(timeoutMatcher.group(1))); 135 136 } else { 136 timeout = 180_000;137 timeout = (int) TimeUnit.MINUTES.toMillis(3); 137 138 } 138 139 request.setConnectTimeout(timeout); -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r10987 r11288 37 37 import java.util.concurrent.ExecutionException; 38 38 import java.util.concurrent.FutureTask; 39 import java.util.concurrent.TimeUnit; 39 40 import java.util.jar.JarFile; 40 41 import java.util.stream.Collectors; … … 384 385 long last = Main.pref.getLong("pluginmanager.lastupdate", 0); 385 386 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); 387 388 if ((last <= 0) || (maxTime <= 0)) { 388 389 Main.pref.put("pluginmanager.lastupdate", Long.toString(tim)); -
trunk/src/org/openstreetmap/josm/tools/ExifReader.java
r10378 r11288 6 6 import java.io.IOException; 7 7 import java.util.Date; 8 import java.util.concurrent.TimeUnit; 8 9 9 10 import org.openstreetmap.josm.Main; … … 70 71 if (subSeconds != null) { 71 72 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))); 73 74 } catch (NumberFormatException e) { 74 75 Main.warn("Failed parsing sub seconds from [{0}]", subSeconds); -
trunk/src/org/openstreetmap/josm/tools/HttpClient.java
r11277 r11288 21 21 import java.util.Scanner; 22 22 import java.util.TreeMap; 23 import java.util.concurrent.TimeUnit; 23 24 import java.util.regex.Matcher; 24 25 import java.util.regex.Pattern; … … 43 44 private URL url; 44 45 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)); 47 48 private byte[] requestBody; 48 49 private long ifModifiedSince; -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r11100 r11288 47 47 import java.util.concurrent.ForkJoinWorkerThread; 48 48 import java.util.concurrent.ThreadFactory; 49 import java.util.concurrent.TimeUnit; 49 50 import java.util.concurrent.atomic.AtomicLong; 50 51 import java.util.function.Function; … … 79 80 public static final Pattern WHITE_SPACES_PATTERN = Pattern.compile("\\s+"); 80 81 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); 85 86 86 87 /** -
trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java
r11048 r11288 13 13 import java.util.Locale; 14 14 import java.util.TimeZone; 15 import java.util.concurrent.TimeUnit; 15 16 16 17 import javax.xml.datatype.DatatypeConfigurationException; … … 145 146 */ 146 147 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); 148 149 return DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(temporal); 149 150 }
Note:
See TracChangeset
for help on using the changeset viewer.