Changeset 15217 in josm for trunk/src/com/drew/metadata/exif/ExifSubIFDDirectory.java
- Timestamp:
- 2019-07-07T01:56:46+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/drew/metadata/exif/ExifSubIFDDirectory.java
r13061 r15217 1 1 /* 2 * Copyright 2002-201 7Drew Noakes2 * Copyright 2002-2019 Drew Noakes and contributors 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 23 23 import com.drew.lang.annotations.NotNull; 24 24 import com.drew.lang.annotations.Nullable; 25 import com.drew.metadata.Directory; 25 26 26 27 import java.util.Date; … … 67 68 68 69 /** 69 * Parses the date/time tag and the subsecond tag to obtain a single Date object with milliseconds 70 * representing the date and time when this image was captured. Attempts will be made to parse the 71 * values as though it is in the GMT {@link TimeZone}. 70 * Parses the date/time tag, the subsecond tag and the time offset tag to obtain a single Date 71 * object with milliseconds representing the date and time when this image was modified. If 72 * the time offset tag does not exist, attempts will be made to parse the values as though it is 73 * in the GMT {@link TimeZone}. 74 * 75 * @return A Date object representing when this image was modified, if possible, otherwise null 76 */ 77 @Nullable 78 public Date getDateModified() 79 { 80 return getDateModified(null); 81 } 82 83 /** 84 * Parses the date/time tag, the subsecond tag and the time offset tag to obtain a single Date 85 * object with milliseconds representing the date and time when this image was modified. If 86 * the time offset tag does not exist, attempts will be made to parse the values as though it is 87 * in the {@link TimeZone} represented by the {@code timeZone} parameter (if it is non-null). 88 * 89 * @param timeZone the time zone to use 90 * @return A Date object representing when this image was modified, if possible, otherwise null 91 */ 92 @Nullable 93 public Date getDateModified(@Nullable TimeZone timeZone) 94 { 95 Directory parent = getParent(); 96 if (parent instanceof ExifIFD0Directory) { 97 TimeZone timeZoneModified = getTimeZone(TAG_OFFSET_TIME); 98 return parent.getDate(TAG_DATETIME, getString(TAG_SUBSECOND_TIME), 99 (timeZoneModified != null) ? timeZoneModified : timeZone); 100 } else { 101 return null; 102 } 103 } 104 105 /** 106 * Parses the date/time tag, the subsecond tag and the time offset tag to obtain a single Date 107 * object with milliseconds representing the date and time when this image was captured. If 108 * the time offset tag does not exist, attempts will be made to parse the values as though it is 109 * in the GMT {@link TimeZone}. 72 110 * 73 111 * @return A Date object representing when this image was captured, if possible, otherwise null … … 80 118 81 119 /** 82 * Parses the date/time tag andthe subsecond tag to obtain a single Dateobject with milliseconds83 * representing the date and time when this image was captured. Attempts will be made to parse the84 * values as though it is in the {@link TimeZone} represented by the {@code timeZone} parameter85 * (if it is non-null). 120 * Parses the date/time tag, the subsecond tag and the time offset tag to obtain a single Date 121 * object with milliseconds representing the date and time when this image was captured. If 122 * the time offset tag does not exist, attempts will be made to parse the values as though it is 123 * in the {@link TimeZone} represented by the {@code timeZone} parameter (if it is non-null). 86 124 * 87 125 * @param timeZone the time zone to use … … 91 129 public Date getDateOriginal(@Nullable TimeZone timeZone) 92 130 { 93 return getDate(TAG_DATETIME_ORIGINAL, getString(TAG_SUBSECOND_TIME_ORIGINAL), timeZone); 131 TimeZone timeZoneOriginal = getTimeZone(TAG_OFFSET_TIME_ORIGINAL); 132 return getDate(TAG_DATETIME_ORIGINAL, getString(TAG_SUBSECOND_TIME_ORIGINAL), 133 (timeZoneOriginal != null) ? timeZoneOriginal : timeZone); 94 134 } 95 135 96 136 /** 97 * Parses the date/time tag and the subsecond tag to obtain a single Date object with milliseconds 98 * representing the date and time when this image was digitized. Attempts will be made to parse the 99 * values as though it is in the GMT {@link TimeZone}. 137 * Parses the date/time tag, the subsecond tag and the time offset tag to obtain a single Date 138 * object with milliseconds representing the date and time when this image was digitized. If 139 * the time offset tag does not exist, attempts will be made to parse the values as though it is 140 * in the GMT {@link TimeZone}. 100 141 * 101 142 * @return A Date object representing when this image was digitized, if possible, otherwise null … … 108 149 109 150 /** 110 * Parses the date/time tag andthe subsecond tag to obtain a single Dateobject with milliseconds111 * representing the date and time when this image was digitized. Attempts will be made to parse the112 * values as though it is in the {@link TimeZone} represented by the {@code timeZone} parameter113 * (if it is non-null). 151 * Parses the date/time tag, the subsecond tag and the time offset tag to obtain a single Date 152 * object with milliseconds representing the date and time when this image was digitized. If 153 * the time offset tag does not exist, attempts will be made to parse the values as though it is 154 * in the {@link TimeZone} represented by the {@code timeZone} parameter (if it is non-null). 114 155 * 115 156 * @param timeZone the time zone to use … … 119 160 public Date getDateDigitized(@Nullable TimeZone timeZone) 120 161 { 121 return getDate(TAG_DATETIME_DIGITIZED, getString(TAG_SUBSECOND_TIME_DIGITIZED), timeZone); 162 TimeZone timeZoneDigitized = getTimeZone(TAG_OFFSET_TIME_DIGITIZED); 163 return getDate(TAG_DATETIME_DIGITIZED, getString(TAG_SUBSECOND_TIME_DIGITIZED), 164 (timeZoneDigitized != null) ? timeZoneDigitized : timeZone); 165 } 166 167 @Nullable 168 private TimeZone getTimeZone(int tagType) 169 { 170 String timeOffset = getString(tagType); 171 if (timeOffset != null && timeOffset.matches("[\\+\\-]\\d\\d:\\d\\d")) { 172 return TimeZone.getTimeZone("GMT" + timeOffset); 173 } else { 174 return null; 175 } 122 176 } 123 177 }
Note:
See TracChangeset
for help on using the changeset viewer.