Changeset 17841 in josm for trunk/src/org
- Timestamp:
- 2021-05-01T12:37:47+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r16671 r17841 16 16 import java.util.Collection; 17 17 import java.util.Collections; 18 import java.util.Date;19 18 import java.util.HashSet; 20 19 import java.util.LinkedList; … … 924 923 private final transient Stack<ZoomData> zoomUndoBuffer = new Stack<>(); 925 924 private final transient Stack<ZoomData> zoomRedoBuffer = new Stack<>(); 926 private Date zoomTimestamp = new Date();925 private long zoomTimestamp = System.currentTimeMillis(); 927 926 928 927 private void pushZoomUndo(EastNorth center, double scale) { 929 Date now = new Date();930 if ((now .getTime() - zoomTimestamp.getTime()) > (Config.getPref().getDouble("zoom.undo.delay", 1.0) * 1000)) {928 long now = System.currentTimeMillis(); 929 if ((now - zoomTimestamp) > (Config.getPref().getDouble("zoom.undo.delay", 1.0) * 1000)) { 931 930 zoomUndoBuffer.push(new ZoomData(center, scale)); 932 931 if (zoomUndoBuffer.size() > Config.getPref().getInt("zoom.undo.max", 50)) { -
trunk/src/org/openstreetmap/josm/gui/io/AbstractUploadTask.java
r16553 r17841 7 7 import java.awt.event.ActionEvent; 8 8 import java.net.HttpURLConnection; 9 import java.text.DateFormat; 9 import java.time.Instant; 10 import java.time.format.FormatStyle; 10 11 import java.util.ArrayList; 11 12 import java.util.Arrays; 12 13 import java.util.Collection; 13 14 import java.util.Collections; 14 import java.util.Date;15 15 import java.util.regex.Matcher; 16 16 import java.util.regex.Pattern; … … 215 215 * @param d changeset date 216 216 */ 217 protected void handleUploadConflictForClosedChangeset(long changesetId, Dated) {217 protected void handleUploadConflictForClosedChangeset(long changesetId, Instant d) { 218 218 String msg = tr("<html>Uploading <strong>failed</strong> because you have been using<br>" 219 219 + "changeset {0} which was already closed at {1}.<br>" 220 220 + "Please upload again with a new or an existing open changeset.</html>", 221 changesetId, DateUtils. formatDateTime(d, DateFormat.SHORT, DateFormat.SHORT)221 changesetId, DateUtils.getDateTimeFormatter(FormatStyle.SHORT, FormatStyle.SHORT).format(d) 222 222 ); 223 223 JOptionPane.showMessageDialog( … … 293 293 m = p.matcher(errorHeader); 294 294 if (m.matches()) { 295 handleUploadConflictForClosedChangeset(Long.parseLong(m.group(1)), DateUtils. fromString(m.group(2)));295 handleUploadConflictForClosedChangeset(Long.parseLong(m.group(1)), DateUtils.parseInstant(m.group(2))); 296 296 return; 297 297 } -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r17786 r17841 26 26 import java.net.MalformedURLException; 27 27 import java.net.URL; 28 import java.t ext.SimpleDateFormat;28 import java.time.Instant; 29 29 import java.util.ArrayList; 30 30 import java.util.Arrays; … … 32 32 import java.util.Collections; 33 33 import java.util.Comparator; 34 import java.util.Date;35 34 import java.util.LinkedList; 36 35 import java.util.List; … … 479 478 String value = e.getValue(); 480 479 if ("lastModification".equals(e.getKey()) || "expirationTime".equals(e.getKey())) { 481 value = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(Long.parseLong(value)));480 value = Instant.ofEpochMilli(Long.parseLong(value)).toString(); 482 481 } 483 482 panel.add(layer.createTextField(value), GBC.eol().fill(GBC.HORIZONTAL)); -
trunk/src/org/openstreetmap/josm/gui/layer/AutosaveTask.java
r17181 r17841 14 14 import java.nio.file.Files; 15 15 import java.nio.file.Path; 16 import java.time.Instant; 16 17 import java.util.ArrayList; 17 18 import java.util.Arrays; … … 190 191 } 191 192 192 protected File getNewLayerFile(AutosaveLayerInfo<?> layer, Datenow, int startIndex) {193 protected File getNewLayerFile(AutosaveLayerInfo<?> layer, Instant now, int startIndex) { 193 194 int index = startIndex; 194 195 while (true) { 195 196 String filename = String.format(Locale.ENGLISH, "%1$s_%2$tY%2$tm%2$td_%2$tH%2$tM%2$tS%2$tL%3$s", 196 layer.layerFileName, now, index == 0 ? "" : ('_' + Integer.toString(index)));197 layer.layerFileName, Date.from(now), index == 0 ? "" : ('_' + Integer.toString(index))); 197 198 File result = new File(autosaveDir, filename + '.' + 198 199 (layer.layer instanceof NoteLayer ? … … 234 235 Data data = info.layer.getData(); 235 236 if (data != null && changedData.remove(data)) { 236 File file = getNewLayerFile(info, new Date(), 0);237 File file = getNewLayerFile(info, Instant.now(), 0); 237 238 if (file != null) { 238 239 info.backupFiles.add(file); -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java
r17715 r17841 16 16 import java.util.Arrays; 17 17 import java.util.Comparator; 18 import java.util.Date;19 18 import java.util.List; 20 19 import java.util.Map; … … 328 327 JComponent jc = (JComponent) c; 329 328 Object value = getValueAt(row, col); 330 jc.setToolTipText(col == 2 ? Arrays.toString(( Date[]) value) : String.valueOf(value));329 jc.setToolTipText(col == 2 ? Arrays.toString((Instant[]) value) : String.valueOf(value)); 331 330 if (content.length > row 332 331 && content[row].length > 5 -
trunk/src/org/openstreetmap/josm/gui/preferences/display/LafPreference.java
r17706 r17841 6 6 import java.awt.Component; 7 7 import java.awt.GridBagLayout; 8 import java.text.DateFormat; 9 import java.util.Date; 8 import java.time.LocalDate; 9 import java.time.ZoneId; 10 import java.time.format.DateTimeFormatter; 11 import java.time.format.FormatStyle; 10 12 11 13 import javax.swing.BorderFactory; … … 177 179 panel.add(dynamicButtons, GBC.eop().insets(20, 0, 0, 0)); 178 180 179 Date today = new Date();181 LocalDate today = LocalDate.now(ZoneId.systemDefault()); 180 182 isoDates.setToolTipText(tr("Format dates according to {0}. Today''s date will be displayed as {1} instead of {2}", 181 183 tr("ISO 8601"), 182 DateUtils.newIsoDateFormat().format(today),183 Date Format.getDateInstance(DateFormat.SHORT).format(today)));184 today.toString(), 185 DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT).format(today))); 184 186 isoDates.setSelected(DateUtils.PROP_ISO_DATES.get()); 185 187 panel.add(isoDates, GBC.eop().insets(20, 0, 0, 0)); -
trunk/src/org/openstreetmap/josm/io/ValidatorErrorWriter.java
r16333 r17841 8 8 import java.io.PrintWriter; 9 9 import java.nio.charset.StandardCharsets; 10 import java.time.Instant; 10 11 import java.util.ArrayList; 11 12 import java.util.Collection; 12 import java.util.Date;13 13 import java.util.HashMap; 14 14 import java.util.List; … … 32 32 import org.openstreetmap.josm.tools.LanguageInfo; 33 33 import org.openstreetmap.josm.tools.Logging; 34 import org.openstreetmap.josm.tools.date.DateUtils;35 34 36 35 /** … … 65 64 public void write(Collection<TestError> validationErrors) throws IOException { 66 65 Set<Test> analysers = validationErrors.stream().map(TestError::getTester).collect(Collectors.toCollection(TreeSet::new)); 67 String timestamp = DateUtils.fromDate(new Date());66 String timestamp = Instant.now().toString(); 68 67 69 68 out.println("<?xml version='1.0' encoding='UTF-8'?>"); -
trunk/src/org/openstreetmap/josm/io/nmea/NmeaReader.java
r17715 r17841 9 9 import java.text.ParsePosition; 10 10 import java.text.SimpleDateFormat; 11 import java.time.Instant; 11 12 import java.util.ArrayList; 12 13 import java.util.Arrays; … … 176 177 private final SimpleDateFormat rmcTimeFmt = new SimpleDateFormat("ddMMyyHHmmss.SSS", Locale.ENGLISH); 177 178 178 private DatereadTime(String p) throws IllegalDataException {179 private Instant readTime(String p) throws IllegalDataException { 179 180 // NMEA defines time with "a variable number of digits for decimal-fraction of seconds" 180 181 // This variable decimal fraction cannot be parsed by SimpleDateFormat … … 190 191 Date d = rmcTimeFmt.parse(date, new ParsePosition(0)); 191 192 if (d != null) 192 return d ;193 return d.toInstant(); 193 194 } 194 195 throw new IllegalDataException("Date is malformed: '" + p + "'"); … … 355 356 // time 356 357 accu = e[GGA.TIME.position]; 357 Date d= readTime(currentDate+accu);358 Instant instant = readTime(currentDate+accu); 358 359 359 360 if ((ps.pTime == null) || (currentwp == null) || !ps.pTime.equals(accu)) { … … 366 367 // As this sentence has no complete time only use it 367 368 // if there is no time so far 368 currentwp.setInstant( d.toInstant());369 currentwp.setInstant(instant); 369 370 } 370 371 // elevation … … 486 487 String time = e[RMC.TIME.position]; 487 488 488 Date d= readTime(currentDate+time);489 Instant instant = readTime(currentDate+time); 489 490 490 491 if (ps.pTime == null || currentwp == null || !ps.pTime.equals(time)) { … … 494 495 } 495 496 // time: this sentence has complete time so always use it. 496 currentwp.setInstant( d.toInstant());497 currentwp.setInstant(instant); 497 498 // speed 498 499 accu = e[RMC.SPEED.position];
Note:
See TracChangeset
for help on using the changeset viewer.