Changeset 17838 in josm for trunk/src/org
- Timestamp:
- 2021-05-01T11:39:00+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmChangeTask.java
r17749 r17838 6 6 import java.time.Instant; 7 7 import java.util.Arrays; 8 import java.util.Date;9 8 import java.util.HashMap; 10 9 import java.util.Iterator; … … 160 159 if (history != null && date != null) { 161 160 // Lookup for the primitive version at the specified timestamp 162 HistoryOsmPrimitive hp = history.getByDate( Date.from(date));161 HistoryOsmPrimitive hp = history.getByDate(date); 163 162 if (hp != null) { 164 163 PrimitiveData data; -
trunk/src/org/openstreetmap/josm/data/osm/history/History.java
r17333 r17838 3 3 4 4 import java.text.MessageFormat; 5 import java.time.Instant; 5 6 import java.util.ArrayList; 6 7 import java.util.Comparator; 7 import java.util.Date;8 8 import java.util.List; 9 9 import java.util.stream.Collectors; … … 86 86 * @return a new partial copy of this history, from the given date 87 87 */ 88 public History from(final DatefromDate) {89 return filter(this, primitive -> primitive.get Timestamp().compareTo(fromDate) >= 0);88 public History from(final Instant fromDate) { 89 return filter(this, primitive -> primitive.getInstant().compareTo(fromDate) >= 0); 90 90 } 91 91 … … 95 95 * @return a new partial copy of this history, until the given date 96 96 */ 97 public History until(final DateuntilDate) {98 return filter(this, primitive -> primitive.get Timestamp().compareTo(untilDate) <= 0);97 public History until(final Instant untilDate) { 98 return filter(this, primitive -> primitive.getInstant().compareTo(untilDate) <= 0); 99 99 } 100 100 … … 105 105 * @return a new partial copy of this history, between the given dates 106 106 */ 107 public History between( Date fromDate, DateuntilDate) {107 public History between(Instant fromDate, Instant untilDate) { 108 108 return this.from(fromDate).until(untilDate); 109 109 } … … 196 196 * @return the history primitive at given <code>date</code> 197 197 */ 198 public HistoryOsmPrimitive getByDate( Datedate) {198 public HistoryOsmPrimitive getByDate(Instant date) { 199 199 History h = sortAscending(); 200 200 201 201 if (h.versions.isEmpty()) 202 202 return null; 203 if (h.get(0).get Timestamp().compareTo(date) > 0)203 if (h.get(0).getInstant().compareTo(date) > 0) 204 204 return null; 205 205 for (int i = 1; i < h.versions.size(); i++) { 206 if (h.get(i-1).get Timestamp().compareTo(date) <= 0207 && h.get(i).get Timestamp().compareTo(date) >= 0)206 if (h.get(i-1).getInstant().compareTo(date) <= 0 207 && h.get(i).getInstant().compareTo(date) >= 0) 208 208 return h.get(i); 209 209 } -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryNode.java
r11878 r17838 2 2 package org.openstreetmap.josm.data.osm.history; 3 3 4 import java. util.Date;4 import java.time.Instant; 5 5 6 6 import org.openstreetmap.josm.data.coor.LatLon; … … 31 31 * @throws IllegalArgumentException if preconditions are violated 32 32 */ 33 public HistoryNode(long id, long version, boolean visible, User user, long changesetId, Datetimestamp, LatLon coords) {33 public HistoryNode(long id, long version, boolean visible, User user, long changesetId, Instant timestamp, LatLon coords) { 34 34 this(id, version, visible, user, changesetId, timestamp, coords, true); 35 35 } … … 50 50 * @since 5440 51 51 */ 52 public HistoryNode(long id, long version, boolean visible, User user, long changesetId, Datetimestamp, LatLon coords,52 public HistoryNode(long id, long version, boolean visible, User user, long changesetId, Instant timestamp, LatLon coords, 53 53 boolean checkHistoricParams) { 54 54 super(id, version, visible, user, changesetId, timestamp, checkHistoricParams); -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryOsmPrimitive.java
r17749 r17838 5 5 6 6 import java.text.MessageFormat; 7 import java.time.Instant; 7 8 import java.util.Collection; 8 9 import java.util.Collections; … … 25 26 import org.openstreetmap.josm.tools.CheckParameterUtil; 26 27 import org.openstreetmap.josm.tools.Logging; 27 import org.openstreetmap.josm.tools.date.DateUtils;28 28 29 29 /** … … 38 38 private final long changesetId; 39 39 private Changeset changeset; 40 private final Datetimestamp;40 private final Instant timestamp; 41 41 private final long version; 42 42 private Map<String, String> tags; … … 54 54 * @throws IllegalArgumentException if preconditions are violated 55 55 */ 56 protected HistoryOsmPrimitive(long id, long version, boolean visible, User user, long changesetId, Datetimestamp) {56 protected HistoryOsmPrimitive(long id, long version, boolean visible, User user, long changesetId, Instant timestamp) { 57 57 this(id, version, visible, user, changesetId, timestamp, true); 58 58 } … … 73 73 * @since 5440 74 74 */ 75 protected HistoryOsmPrimitive(long id, long version, boolean visible, User user, long changesetId, Datetimestamp,75 protected HistoryOsmPrimitive(long id, long version, boolean visible, User user, long changesetId, Instant timestamp, 76 76 boolean checkHistoricParams) { 77 77 ensurePositiveLong(id, "id"); … … 87 87 this.user = user; 88 88 this.changesetId = changesetId; 89 this.timestamp = DateUtils.cloneDate(timestamp);89 this.timestamp = timestamp; 90 90 this.tags = new HashMap<>(); 91 91 } … … 96 96 */ 97 97 protected HistoryOsmPrimitive(OsmPrimitive p) { 98 this(p.getId(), p.getVersion(), p.isVisible(), p.getUser(), p.getChangesetId(), Date.from(p.getInstant()));98 this(p.getId(), p.getVersion(), p.isVisible(), p.getUser(), p.getChangesetId(), p.getInstant()); 99 99 } 100 100 … … 159 159 * Returns the timestamp. 160 160 * @return the timestamp 161 */ 161 * @deprecated Use {@link #getInstant()} 162 */ 163 @Deprecated 162 164 public Date getTimestamp() { 163 return DateUtils.cloneDate(timestamp); 165 return Date.from(timestamp); 166 } 167 168 /** 169 * Returns the timestamp. 170 * @return the timestamp 171 */ 172 public Instant getInstant() { 173 return timestamp; 164 174 } 165 175 … … 364 374 Logging.log(Logging.LEVEL_ERROR, "Cannot change visibility for "+data+':', e); 365 375 } 366 data.setInstant(timestamp .toInstant());376 data.setInstant(timestamp); 367 377 data.setKeys(tags); 368 378 data.setOsmId(id, (int) version); -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryRelation.java
r11878 r17838 3 3 4 4 import java.text.MessageFormat; 5 import java.time.Instant; 5 6 import java.util.ArrayList; 6 7 import java.util.Collections; 7 import java.util.Date;8 8 import java.util.List; 9 9 … … 35 35 * @throws IllegalArgumentException if preconditions are violated 36 36 */ 37 public HistoryRelation(long id, long version, boolean visible, User user, long changesetId, Datetimestamp) {37 public HistoryRelation(long id, long version, boolean visible, User user, long changesetId, Instant timestamp) { 38 38 super(id, version, visible, user, changesetId, timestamp); 39 39 } … … 53 53 * @since 5440 54 54 */ 55 public HistoryRelation(long id, long version, boolean visible, User user, long changesetId, Datetimestamp, boolean checkHistoricParams) {55 public HistoryRelation(long id, long version, boolean visible, User user, long changesetId, Instant timestamp, boolean checkHistoricParams) { 56 56 super(id, version, visible, user, changesetId, timestamp, checkHistoricParams); 57 57 } … … 70 70 * @throws IllegalArgumentException if preconditions are violated 71 71 */ 72 public HistoryRelation(long id, long version, boolean visible, User user, long changesetId, Datetimestamp,72 public HistoryRelation(long id, long version, boolean visible, User user, long changesetId, Instant timestamp, 73 73 List<RelationMemberData> members) { 74 74 this(id, version, visible, user, changesetId, timestamp); -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryWay.java
r15121 r17838 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.time.Instant; 6 7 import java.util.ArrayList; 7 8 import java.util.Collections; 8 import java.util.Date;9 9 import java.util.List; 10 10 import java.util.Objects; … … 35 35 * @throws IllegalArgumentException if preconditions are violated 36 36 */ 37 public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Datetimestamp) {37 public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Instant timestamp) { 38 38 super(id, version, visible, user, changesetId, timestamp); 39 39 } … … 53 53 * @since 5440 54 54 */ 55 public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Datetimestamp, boolean checkHistoricParams) {55 public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Instant timestamp, boolean checkHistoricParams) { 56 56 super(id, version, visible, user, changesetId, timestamp, checkHistoricParams); 57 57 } … … 69 69 * @throws IllegalArgumentException if preconditions are violated 70 70 */ 71 public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Datetimestamp, List<Long> nodeIdList) {71 public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Instant timestamp, List<Long> nodeIdList) { 72 72 this(id, version, visible, user, changesetId, timestamp); 73 73 CheckParameterUtil.ensureParameterNotNull(nodeIdList, "nodeIdList"); -
trunk/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java
r17749 r17838 11 11 import java.awt.Insets; 12 12 import java.awt.event.ActionEvent; 13 import java.text.DateFormat; 13 import java.time.Instant; 14 import java.time.format.FormatStyle; 14 15 import java.util.Collections; 15 import java.util.Date;16 16 17 17 import javax.swing.AbstractAction; … … 170 170 } 171 171 172 protected String getInfoText(final Datetimestamp, final long version, final boolean isLatest) {172 protected String getInfoText(final Instant timestamp, final long version, final boolean isLatest) { 173 173 String text; 174 174 if (isLatest) { … … 181 181 String date = "?"; 182 182 if (timestamp != null) { 183 date = DateUtils. formatDateTime(timestamp, DateFormat.SHORT, DateFormat.SHORT);183 date = DateUtils.getDateTimeFormatter(FormatStyle.SHORT, FormatStyle.SHORT).format(timestamp); 184 184 } 185 185 text = tr( … … 226 226 if (primitive != null) { 227 227 Changeset cs = primitive.getChangeset(); 228 update(cs, model.isLatest(primitive), primitive.get Timestamp(), primitive.getVersion(), primitive.getPrimitiveId());228 update(cs, model.isLatest(primitive), primitive.getInstant(), primitive.getVersion(), primitive.getPrimitiveId()); 229 229 } 230 230 } … … 236 236 */ 237 237 public void update(final OsmPrimitive primitive, final boolean isLatest) { 238 Date timestamp = Date.from(primitive.getInstant()); 239 update(Changeset.fromPrimitive(primitive), isLatest, timestamp, primitive.getVersion(), primitive.getPrimitiveId()); 238 update(Changeset.fromPrimitive(primitive), isLatest, primitive.getInstant(), primitive.getVersion(), primitive.getPrimitiveId()); 240 239 } 241 240 … … 249 248 * @since 14432 250 249 */ 251 public void update(final Changeset cs, final boolean isLatest, final Datetimestamp, final long version, final PrimitiveId id) {250 public void update(final Changeset cs, final boolean isLatest, final Instant timestamp, final long version, final PrimitiveId id) { 252 251 lblInfo.setText(getInfoText(timestamp, version, isLatest)); 253 252 primitiveId = id; -
trunk/src/org/openstreetmap/josm/gui/history/VersionTableModel.java
r12620 r17838 2 2 package org.openstreetmap.josm.gui.history; 3 3 4 import java.t ext.DateFormat;4 import java.time.format.FormatStyle; 5 5 6 6 import javax.swing.table.AbstractTableModel; … … 53 53 case VersionTableColumnModel.COL_DATE: 54 54 HistoryOsmPrimitive p3 = model.getPrimitive(row); 55 if (p3 != null && p3.get Timestamp() != null)56 return DateUtils. formatDateTime(p3.getTimestamp(), DateFormat.SHORT, DateFormat.SHORT);55 if (p3 != null && p3.getInstant() != null) 56 return DateUtils.getDateTimeFormatter(FormatStyle.SHORT, FormatStyle.SHORT).format(p3.getInstant()); 57 57 return null; 58 58 case VersionTableColumnModel.COL_USER: -
trunk/src/org/openstreetmap/josm/io/AbstractParser.java
r14946 r17838 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java. util.Date;6 import java.time.Instant; 7 7 8 8 import org.openstreetmap.josm.data.coor.LatLon; … … 132 132 133 133 String v = getMandatoryAttributeString(atts, "timestamp"); 134 Date timestamp = DateUtils.fromString(v);134 Instant timestamp = DateUtils.parseInstant(v); 135 135 HistoryOsmPrimitive primitive = null; 136 136 if (type == OsmPrimitiveType.NODE) {
Note:
See TracChangeset
for help on using the changeset viewer.