Changeset 9383 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2016-01-10T13:04:06+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ExifReader.java
r8509 r9383 5 5 import java.io.File; 6 6 import java.io.IOException; 7 import java.text.ParseException;8 7 import java.util.Date; 9 8 10 9 import org.openstreetmap.josm.Main; 11 10 import org.openstreetmap.josm.data.coor.LatLon; 12 import org.openstreetmap.josm.tools.date. PrimaryDateParser;11 import org.openstreetmap.josm.tools.date.DateUtils; 13 12 14 13 import com.drew.imaging.jpeg.JpegMetadataReader; … … 38 37 * @param filename The JPEG file to read 39 38 * @return The date/time read in the EXIF section, or {@code null} if not found 40 * @throws ParseException if {@link PrimaryDateParser#parse} fails to parse date/time 41 */ 42 public static Date readTime(File filename) throws ParseException { 39 */ 40 public static Date readTime(File filename) { 43 41 try { 44 42 Metadata metadata = JpegMetadataReader.readMetadata(filename); … … 60 58 if (dateStr != null) { 61 59 dateStr = dateStr.replace('/', ':'); // workaround for HTC Sensation bug, see #7228 62 return new PrimaryDateParser().parse(dateStr); 63 } 64 } catch (ParseException e) { 65 throw e; 60 return DateUtils.fromString(dateStr); 61 } 66 62 } catch (Exception e) { 67 63 Main.error(e); -
trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java
r9059 r9383 45 45 * with the timezone lookup, is very expensive. 46 46 */ 47 private static GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); 47 private static final GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); 48 private static final GregorianCalendar calendarLocale = new GregorianCalendar(TimeZone.getDefault()); 48 49 private static final DatatypeFactory XML_DATE; 49 50 50 51 static { 51 52 calendar.setTimeInMillis(0); 53 calendarLocale.setTimeInMillis(0); 52 54 53 55 DatatypeFactory fact = null; … … 78 80 if (checkLayout(str, "xxxx-xx-xxTxx:xx:xxZ") || 79 81 checkLayout(str, "xxxx-xx-xxTxx:xx:xx") || 82 checkLayout(str, "xxxx:xx:xx xx:xx:xx") || 80 83 checkLayout(str, "xxxx-xx-xx xx:xx:xx UTC") || 81 84 checkLayout(str, "xxxx-xx-xxTxx:xx:xx+xx:00") || 82 85 checkLayout(str, "xxxx-xx-xxTxx:xx:xx-xx:00")) { 83 calendar.set( 86 final Calendar c = checkLayout(str, "xxxx:xx:xx xx:xx:xx") ? calendarLocale : calendar; // consider EXIF date in default timezone 87 c.set( 84 88 parsePart4(str, 0), 85 89 parsePart2(str, 5)-1, … … 92 96 int plusHr = parsePart2(str, 20); 93 97 int mul = str.charAt(19) == '+' ? -3600000 : 3600000; 94 return c alendar.getTimeInMillis()+plusHr*mul;98 return c.getTimeInMillis()+plusHr*mul; 95 99 } 96 100 97 return c alendar.getTimeInMillis();101 return c.getTimeInMillis(); 98 102 } else if (checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxxZ") || 99 103 checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxx") || 104 checkLayout(str, "xxxx:xx:xx xx:xx:xx.xxx") || 100 105 checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxx+xx:00") || 101 106 checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxx-xx:00")) { 102 calendar.set( 107 final Calendar c = checkLayout(str, "xxxx:xx:xx xx:xx:xx.xxx") ? calendarLocale : calendar; // consider EXIF date in default timezone 108 c.set( 103 109 parsePart4(str, 0), 104 110 parsePart2(str, 5)-1, … … 112 118 } 113 119 114 return c alendar.getTimeInMillis() + millis;120 return c.getTimeInMillis() + millis; 115 121 } else { 116 122 // example date format "18-AUG-08 13:33:03" -
trunk/src/org/openstreetmap/josm/tools/date/PrimaryDateParser.java
r9078 r9383 17 17 * 18 18 * @author Brett Henderson 19 * @deprecated Use {@link DateUtils} instead! 19 20 */ 21 @Deprecated 20 22 public class PrimaryDateParser { 21 23 private DatatypeFactory datatypeFactory;
Note:
See TracChangeset
for help on using the changeset viewer.