Index: /trunk/src/org/openstreetmap/josm/tools/ExifReader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/ExifReader.java	(revision 11513)
+++ /trunk/src/org/openstreetmap/josm/tools/ExifReader.java	(revision 11514)
@@ -44,4 +44,5 @@
             Metadata metadata = JpegMetadataReader.readMetadata(filename);
             String dateStr = null;
+            String dateTime = null;
             String subSeconds = null;
             for (Directory dirIt : metadata.getDirectories()) {
@@ -52,12 +53,13 @@
                     if (tag.getTagType() == ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL /* 0x9003 */ &&
                             !tag.getDescription().matches("\\[[0-9]+ .+\\]")) {
+                        // prefer DATETIME_ORIGINAL
                         dateStr = tag.getDescription();
                     }
-                    if (tag.getTagType() == ExifIFD0Directory.TAG_DATETIME /* 0x0132 */ ||
-                        tag.getTagType() == ExifSubIFDDirectory.TAG_DATETIME_DIGITIZED /* 0x9004 */) {
-                        if (dateStr == null) {
-                            // prefer TAG_DATETIME_ORIGINAL
-                            dateStr = tag.getDescription();
-                        }
+                    if (tag.getTagType() == ExifIFD0Directory.TAG_DATETIME /* 0x0132 */) {
+                        // prefer DATETIME over DATETIME_DIGITIZED
+                        dateTime = tag.getDescription();
+                    }
+                    if (tag.getTagType() == ExifSubIFDDirectory.TAG_DATETIME_DIGITIZED /* 0x9004 */ && dateTime == null) {
+                        dateTime = tag.getDescription();
                     }
                     if (tag.getTagType() == ExifIFD0Directory.TAG_SUBSECOND_TIME_ORIGINAL) {
@@ -65,4 +67,7 @@
                     }
                 }
+            }
+            if (dateStr == null) {
+                dateStr = dateTime;
             }
             if (dateStr != null) {
Index: /trunk/test/unit/org/openstreetmap/josm/tools/ExifReaderTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/tools/ExifReaderTest.java	(revision 11513)
+++ /trunk/test/unit/org/openstreetmap/josm/tools/ExifReaderTest.java	(revision 11514)
@@ -24,4 +24,5 @@
 
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
 /**
  * EXIF metadata extraction test
@@ -70,12 +71,18 @@
     public void testReadTimeSubSecond1() throws ParseException {
         Date date = ExifReader.readTime(new File("data_nodist/IMG_20150711_193419.jpg"));
-        String dateStr = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").format(date);
-        assertEquals("2015-07-11T19:34:19.100", dateStr);
+        doTest("2015-07-11T19:34:19.100", date);
 
         TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin"));
         date = ExifReader.readTime(new File("data_nodist/IMG_20150711_193419.jpg"));
         TimeZone.setDefault(DateUtils.UTC);
-        dateStr = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").format(date);
-        assertEquals("2015-07-11T17:34:19.100", dateStr);
+        doTest("2015-07-11T17:34:19.100", date);
+    }
+
+    private static void doTest(String expectedDate, Date parsedDate) {
+        assertEquals(expectedDate, new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").format(parsedDate));
+    }
+
+    private static void doTestFile(String expectedDate, int ticket, String filename) {
+        doTest(expectedDate, ExifReader.readTime(new File(TestUtils.getRegressionDataFile(ticket, filename))));
     }
 
@@ -115,7 +122,5 @@
     @Test
     public void testTicket11685() throws IOException {
-        File file = new File(TestUtils.getRegressionDataFile(11685, "2015-11-08_15-33-27-Xiaomi_YI-Y0030832.jpg"));
-        String dateStr = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").format(ExifReader.readTime(file));
-        assertEquals("2015-11-08T15:33:27.500", dateStr);
+        doTestFile("2015-11-08T15:33:27.500", 11685, "2015-11-08_15-33-27-Xiaomi_YI-Y0030832.jpg");
     }
 
@@ -126,7 +131,6 @@
     @Test
     public void testTicket14209() throws IOException {
-        File file = new File(TestUtils.getRegressionDataFile(14209, "0MbEfj1S--.1.jpg"));
-        String dateStr = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").format(ExifReader.readTime(file));
-        assertEquals("2017-01-16T18:27:00.000", dateStr);
+        doTestFile("2017-01-16T18:27:00.000", 14209, "0MbEfj1S--.1.jpg");
+        doTestFile("2016-08-13T19:51:13.000", 14209, "7VWFOryj--.1.jpg");
     }
 }
