Changeset 17715 in josm for trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
- Timestamp:
- 2021-04-08T22:56:06+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r17439 r17715 10 10 import java.awt.event.ActionEvent; 11 11 import java.io.File; 12 import java.text.DateFormat; 12 import java.time.Instant; 13 import java.time.format.DateTimeFormatter; 14 import java.time.format.FormatStyle; 15 import java.time.temporal.ChronoUnit; 13 16 import java.util.ArrayList; 14 17 import java.util.Arrays; … … 157 160 */ 158 161 public static String getTimespanForTrack(IGpxTrack trk) { 159 Date[] bounds = GpxData.getMinMaxTimeForTrack(trk);162 Instant[] bounds = GpxData.getMinMaxTimeForTrack(trk); 160 163 return bounds != null ? formatTimespan(bounds) : ""; 161 164 } … … 166 169 * @return The timespan as a string 167 170 */ 168 public static String formatTimespan( Date[] bounds) {171 public static String formatTimespan(Instant[] bounds) { 169 172 String ts = ""; 170 Date Formatdf = DateUtils.getDateFormat(DateFormat.SHORT);173 DateTimeFormatter df = DateUtils.getDateFormatter(FormatStyle.SHORT); 171 174 String earliestDate = df.format(bounds[0]); 172 175 String latestDate = df.format(bounds[1]); 173 176 174 177 if (earliestDate.equals(latestDate)) { 175 Date Formattf = DateUtils.getTimeFormat(DateFormat.SHORT);178 DateTimeFormatter tf = DateUtils.getTimeFormatter(FormatStyle.SHORT); 176 179 ts += earliestDate + ' '; 177 180 ts += tf.format(bounds[0]) + " - " + tf.format(bounds[1]); 178 181 } else { 179 Date Formatdtf = DateUtils.getDateTimeFormat(DateFormat.SHORT,DateFormat.MEDIUM);182 DateTimeFormatter dtf = DateUtils.getDateTimeFormatter(FormatStyle.SHORT, FormatStyle.MEDIUM); 180 183 ts += dtf.format(bounds[0]) + " - " + dtf.format(bounds[1]); 181 184 } 182 185 183 intdiff =(int)(bounds[1].getTime() -bounds[0].getTime()) / 1000;186 long diff = ChronoUnit.SECONDS.between(bounds[1], bounds[0]); 184 187 ts += String.format(" (%d:%02d)", diff / 3600, (diff % 3600) / 60); 185 188 return ts; … … 355 358 long to = toDate.getTime(); 356 359 for (IGpxTrack trk : data.getTracks()) { 357 Date[] t = GpxData.getMinMaxTimeForTrack(trk);360 Instant[] t = GpxData.getMinMaxTimeForTrack(trk); 358 361 359 362 if (t == null) continue; 360 long tm = t[1]. getTime();363 long tm = t[1].toEpochMilli(); 361 364 trackVisibility[i] = (tm == 0 && showWithoutDate) || (from <= tm && tm <= to); 362 365 i++;
Note:
See TracChangeset
for help on using the changeset viewer.
