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

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

Location:
trunk/src/org/openstreetmap/josm/tools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • 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.