Changeset 10862 in josm for trunk/src/com/drew/metadata/exif/GpsDirectory.java
- Timestamp:
- 2016-08-20T20:58:03+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/drew/metadata/exif/GpsDirectory.java
r8243 r10862 1 1 /* 2 * Copyright 2002-201 5Drew Noakes2 * Copyright 2002-2016 Drew Noakes 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 26 26 import com.drew.lang.annotations.Nullable; 27 27 28 import java.text.DateFormat; 29 import java.text.ParseException; 30 import java.text.SimpleDateFormat; 31 import java.util.Date; 28 32 import java.util.HashMap; 33 import java.util.Locale; 29 34 30 35 /** … … 164 169 public GeoLocation getGeoLocation() 165 170 { 166 Rational[] latitudes = getRationalArray( GpsDirectory.TAG_LATITUDE);167 Rational[] longitudes = getRationalArray( GpsDirectory.TAG_LONGITUDE);168 String latitudeRef = getString( GpsDirectory.TAG_LATITUDE_REF);169 String longitudeRef = getString( GpsDirectory.TAG_LONGITUDE_REF);171 Rational[] latitudes = getRationalArray(TAG_LATITUDE); 172 Rational[] longitudes = getRationalArray(TAG_LONGITUDE); 173 String latitudeRef = getString(TAG_LATITUDE_REF); 174 String longitudeRef = getString(TAG_LONGITUDE_REF); 170 175 171 176 // Make sure we have the required values … … 186 191 return new GeoLocation(lat, lon); 187 192 } 193 194 /** 195 * Parses the date stamp tag and the time stamp tag to obtain a single Date object representing the 196 * date and time when this image was captured. 197 * 198 * @return A Date object representing when this image was captured, if possible, otherwise null 199 */ 200 @Nullable 201 public Date getGpsDate() 202 { 203 String date = getString(TAG_DATE_STAMP); 204 Rational[] timeComponents = getRationalArray(TAG_TIME_STAMP); 205 206 // Make sure we have the required values 207 if (date == null) 208 return null; 209 if (timeComponents == null || timeComponents.length != 3) 210 return null; 211 212 String dateTime = String.format(Locale.US, "%s %02d:%02d:%02.3f UTC", 213 date, timeComponents[0].intValue(), timeComponents[1].intValue(), timeComponents[2].doubleValue()); 214 try { 215 DateFormat parser = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss.S z"); 216 return parser.parse(dateTime); 217 } catch (ParseException e) { 218 return null; 219 } 220 } 188 221 }
Note:
See TracChangeset
for help on using the changeset viewer.