Changeset 16941 in josm for trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
- Timestamp:
- 2020-08-26T23:18:49+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r16867 r16941 157 157 public static String getTimespanForTrack(IGpxTrack trk) { 158 158 Date[] bounds = GpxData.getMinMaxTimeForTrack(trk); 159 return bounds != null ? formatTimespan(bounds) : ""; 160 } 161 162 /** 163 * Formats the timespan of the given track as a human readable string 164 * @param bounds The bounds to format, i.e., an array containing the min/max date 165 * @return The timespan as a string 166 */ 167 public static String formatTimespan(Date[] bounds) { 159 168 String ts = ""; 160 if (bounds != null) { 161 DateFormat df = DateUtils.getDateFormat(DateFormat.SHORT); 162 String earliestDate = df.format(bounds[0]); 163 String latestDate = df.format(bounds[1]); 164 165 if (earliestDate.equals(latestDate)) { 166 DateFormat tf = DateUtils.getTimeFormat(DateFormat.SHORT); 167 ts += earliestDate + ' '; 168 ts += tf.format(bounds[0]) + " - " + tf.format(bounds[1]); 169 } else { 170 DateFormat dtf = DateUtils.getDateTimeFormat(DateFormat.SHORT, DateFormat.MEDIUM); 171 ts += dtf.format(bounds[0]) + " - " + dtf.format(bounds[1]); 172 } 173 174 int diff = (int) (bounds[1].getTime() - bounds[0].getTime()) / 1000; 175 ts += String.format(" (%d:%02d)", diff / 3600, (diff % 3600) / 60); 176 } 169 DateFormat df = DateUtils.getDateFormat(DateFormat.SHORT); 170 String earliestDate = df.format(bounds[0]); 171 String latestDate = df.format(bounds[1]); 172 173 if (earliestDate.equals(latestDate)) { 174 DateFormat tf = DateUtils.getTimeFormat(DateFormat.SHORT); 175 ts += earliestDate + ' '; 176 ts += tf.format(bounds[0]) + " - " + tf.format(bounds[1]); 177 } else { 178 DateFormat dtf = DateUtils.getDateTimeFormat(DateFormat.SHORT, DateFormat.MEDIUM); 179 ts += dtf.format(bounds[0]) + " - " + dtf.format(bounds[1]); 180 } 181 182 int diff = (int) (bounds[1].getTime() - bounds[0].getTime()) / 1000; 183 ts += String.format(" (%d:%02d)", diff / 3600, (diff % 3600) / 60); 177 184 return ts; 178 185 }
Note:
See TracChangeset
for help on using the changeset viewer.