diff --git a/importPicture/src/osm/jp/gpx/ImportPicture.java b/importPicture/src/osm/jp/gpx/ImportPicture.java index a3819f2..9eefb5c 100644 --- a/importPicture/src/osm/jp/gpx/ImportPicture.java +++ b/importPicture/src/osm/jp/gpx/ImportPicture.java @@ -295,7 +295,7 @@ Document document; public static final String TIME_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ss'Z'"; - public static final String EXIF_DATE_TIME_FORMAT_STRING = "yyyy:MM:dd HH:mm:ss"; + private static final String EXIF_DATE_TIME_FORMAT_STRING = "yyyy:MM:dd HH:mm:ss"; //public static final SimpleDateFormat DATE_PARSE = new SimpleDateFormat(TIME_FORMAT_STRING +" Z"); //public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(TIME_FORMAT_STRING); //public static final SimpleDateFormat EXIF_DATE_TIME_PARSE = new SimpleDateFormat(EXIF_DATE_TIME_FORMAT_STRING + " Z"); @@ -771,15 +771,28 @@ return wpt; } + /** + * DateをEXIFの文字列に変換する。 + * 注意:EXiFの撮影時刻はUTC時間ではない + * @param localdate + * @return + */ public static String toEXIFString(Date localdate) { DateFormat dfUTC = new SimpleDateFormat(EXIF_DATE_TIME_FORMAT_STRING); - dfUTC.setTimeZone(TimeZone.getTimeZone("UTC")); + //dfUTC.setTimeZone(TimeZone.getTimeZone("UTC")); return dfUTC.format(localdate); } + /** + * EXIFの文字列をDateに変換する。 + * 注意:EXiFの撮影時刻はUTC時間ではない + * @param timeStr + * @return + * @throws ParseException + */ public static Date toEXIFDate(String timeStr) throws ParseException { DateFormat dfUTC = new SimpleDateFormat(EXIF_DATE_TIME_FORMAT_STRING); - dfUTC.setTimeZone(TimeZone.getTimeZone("UTC")); + //dfUTC.setTimeZone(TimeZone.getTimeZone("UTC")); return dfUTC.parse(timeStr); } diff --git a/importPicture/test/osm/jp/gpx/ImportPictureTest.java b/importPicture/test/osm/jp/gpx/ImportPictureTest.java index f017baa..3a10d83 100644 --- a/importPicture/test/osm/jp/gpx/ImportPictureTest.java +++ b/importPicture/test/osm/jp/gpx/ImportPictureTest.java @@ -397,16 +397,16 @@ new Expecter("separate/separate_.gpx", true, null, true), // out of time ( - 2017-05-29T01:23:18) - new Expecter("separate/20170529_102305A.jpg", true, "2017:05:29 10:23:06", true), + new Expecter("separate/20170529_102305A.jpg", true, "2017:05:29 10:23:05", true), new Expecter("separate/20170529_102314A.jpg", true, "2017:05:29 10:23:14", true), // in TRKSEG(1) (2017-05-29T01:23:18 - 2017-05-29T01:24:05) new Expecter("separate/20170529_102318A.jpg", true, "2017:05:29 10:23:18",true), new Expecter("separate/20170529_102322A.jpg", true, "2017:05:29 10:23:22",true), - new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 10:24:04",true), + new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 10:24:05",true), // out of time (2017-05-29T01:24:05 - 2017-05-29T01:24:37) - new Expecter("separate/20170529_102409A.jpg", true, "2017:05:29 10:24:10",true), + new Expecter("separate/20170529_102409A.jpg", true, "2017:05:29 10:24:09",true), new Expecter("separate/20170529_102418A.jpg", true, "2017:05:29 10:24:18",true), // in TRKSEG(2) (2017-05-29T01:24:37 - 2017-05-29T01:33:03) @@ -414,12 +414,12 @@ new Expecter("separate/20170529_103246A.jpg", true, "2017:05:29 10:32:46",true), // out of time (2017-05-29T01:33:03 - 2017-05-29T01:35:53) - new Expecter("separate/20170529_103315A.jpg", true, "2017:05:29 10:33:14",true), - new Expecter("separate/20170529_103545A.jpg", true, "2017:05:29 10:35:44",true), + new Expecter("separate/20170529_103315A.jpg", true, "2017:05:29 10:33:15",true), + new Expecter("separate/20170529_103545A.jpg", true, "2017:05:29 10:35:45",true), // in TRKSEG(3) (2017-05-29T01:35:53 - 2017-05-29T01:47:35) new Expecter("separate/20170529_103615A.jpg", true, "2017:05:29 10:36:14",true), - new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 10:41:18",true), + new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 10:41:19",true), }), new Fixture( @@ -439,7 +439,7 @@ // in TRKSEG(1) (2017-05-29T01:23:18 - 2017-05-29T01:24:05) new Expecter("separate/20170529_102318A.jpg", true, "2017:05:29 10:23:18",true), new Expecter("separate/20170529_102322A.jpg", true, "2017:05:29 10:23:22",true), - new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 10:24:05",true), + new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 10:24:04",true), // out of time (2017-05-29T01:24:05 - 2017-05-29T01:24:37) new Expecter("separate/20170529_102409A.jpg", false, null, false), @@ -455,7 +455,7 @@ // in TRKSEG(3) (2017-05-29T01:35:53 - 2017-05-29T01:47:35) new Expecter("separate/20170529_103615A.jpg", true, "2017:05:29 10:36:14",true), - new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 10:41:19",true), + new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 10:41:18",true), }), new Fixture( @@ -541,16 +541,16 @@ new Expecter("separate/separate_.gpx", true, null, true), // out of time ( - 2017-05-29T01:23:18) - new Expecter("separate/20170529_102305A.jpg", true, "2017:05:29 10:23:06", true), + new Expecter("separate/20170529_102305A.jpg", true, "2017:05:29 10:23:05", true), new Expecter("separate/20170529_102314A.jpg", true, "2017:05:29 10:23:14", true), // in TRKSEG(1) (2017-05-29T01:23:18 - 2017-05-29T01:24:05) new Expecter("separate/20170529_102318A.jpg", true, "2017:05:29 10:23:18",true), new Expecter("separate/20170529_102322A.jpg", true, "2017:05:29 10:23:22",true), - new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 10:24:04",true), + new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 10:24:05",true), // out of time (2017-05-29T01:24:05 - 2017-05-29T01:24:37) - new Expecter("separate/20170529_102409A.jpg", true, "2017:05:29 10:24:10",true), + new Expecter("separate/20170529_102409A.jpg", true, "2017:05:29 10:24:09",true), new Expecter("separate/20170529_102418A.jpg", true, "2017:05:29 10:24:18",true), // in TRKSEG(2) (2017-05-29T01:24:37 - 2017-05-29T01:33:03) @@ -558,12 +558,12 @@ new Expecter("separate/20170529_103246A.jpg", true, "2017:05:29 10:32:46",true), // out of time (2017-05-29T01:33:03 - 2017-05-29T01:35:53) - new Expecter("separate/20170529_103315A.jpg", true, "2017:05:29 10:33:14",true), - new Expecter("separate/20170529_103545A.jpg", true, "2017:05:29 10:35:44",true), + new Expecter("separate/20170529_103315A.jpg", true, "2017:05:29 10:33:15",true), + new Expecter("separate/20170529_103545A.jpg", true, "2017:05:29 10:35:45",true), // in TRKSEG(3) (2017-05-29T01:35:53 - 2017-05-29T01:47:35) new Expecter("separate/20170529_103615A.jpg", true, "2017:05:29 10:36:14",true), - new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 10:41:18",true), + new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 10:41:19",true), }), };