Changeset 17715 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2021-04-08T22:56:06+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ExifReader.java
r17548 r17715 6 6 import java.io.IOException; 7 7 import java.time.DateTimeException; 8 import java.time.Instant; 8 9 import java.util.Date; 9 10 import java.util.List; … … 42 43 * @param filename The JPEG file to read 43 44 * @return The date/time read in the EXIF section, or {@code null} if not found 44 */ 45 * @deprecated Use {@link #readInstant(File)} 46 */ 47 @Deprecated 45 48 public static Date readTime(File filename) { 46 try { 47 final Metadata metadata = JpegMetadataReader.readMetadata(filename); 48 return readTime(metadata); 49 Instant instant = readInstant(filename); 50 return instant == null ? null : Date.from(instant); 51 } 52 53 /** 54 * Returns the date/time from the given JPEG file. 55 * @param filename The JPEG file to read 56 * @return The date/time read in the EXIF section, or {@code null} if not found 57 */ 58 public static Instant readInstant(File filename) { 59 try { 60 final Metadata metadata = JpegMetadataReader.readMetadata(filename); 61 return readInstant(metadata); 49 62 } catch (JpegProcessingException | IOException e) { 50 63 Logging.error(e); … … 58 71 * @return The date/time read in the EXIF section, or {@code null} if not found 59 72 * @since 11745 60 */ 73 * @deprecated Use {@link #readInstant(Metadata)} 74 */ 75 @Deprecated 61 76 public static Date readTime(Metadata metadata) { 77 Instant instant = readInstant(metadata); 78 return instant == null ? null : Date.from(instant); 79 } 80 81 /** 82 * Returns the date/time from the given JPEG file. 83 * @param metadata The EXIF metadata 84 * @return The date/time read in the EXIF section, or {@code null} if not found 85 */ 86 public static Instant readInstant(Metadata metadata) { 62 87 try { 63 88 String dateTimeOrig = null; … … 109 134 if (dateStr != null) { 110 135 dateStr = dateStr.replace('/', ':'); // workaround for HTC Sensation bug, see #7228 111 final Date date = DateUtils.fromString(dateStr);136 Instant date = DateUtils.parseInstant(dateStr); 112 137 if (subSeconds != null) { 113 138 try { 114 date .setTime(date.getTime() +(long) (TimeUnit.SECONDS.toMillis(1) * Double.parseDouble("0." + subSeconds)));139 date = date.plusMillis((long) (TimeUnit.SECONDS.toMillis(1) * Double.parseDouble("0." + subSeconds))); 115 140 } catch (NumberFormatException e) { 116 141 Logging.warn("Failed parsing sub seconds from [{0}]", subSeconds); -
trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java
r17712 r17715 287 287 * @return the date format used for GPX waypoints 288 288 * @since 14055 289 */ 289 * @deprecated Use {@link Instant#toString()} 290 */ 291 @Deprecated 290 292 public static DateFormat getGpxFormat() { 291 293 SimpleDateFormat result = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
Note:
See TracChangeset
for help on using the changeset viewer.