Changeset 10862 in josm for trunk/src/com/drew/metadata/iptc/IptcDirectory.java
- Timestamp:
- 2016-08-20T20:58:03+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/drew/metadata/iptc/IptcDirectory.java
r8132 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"); … … 25 25 import com.drew.metadata.Directory; 26 26 27 import java.text.DateFormat; 28 import java.text.ParseException; 29 import java.text.SimpleDateFormat; 27 30 import java.util.Arrays; 31 import java.util.Date; 28 32 import java.util.HashMap; 29 33 import java.util.List; … … 231 235 public List<String> getKeywords() 232 236 { 233 final String[] array = getStringArray( IptcDirectory.TAG_KEYWORDS);237 final String[] array = getStringArray(TAG_KEYWORDS); 234 238 if (array==null) 235 239 return null; 236 240 return Arrays.asList(array); 237 241 } 242 243 /** 244 * Parses the Date Sent tag and the Time Sent tag to obtain a single Date object representing the 245 * date and time when the service sent this image. 246 * @return A Date object representing when the service sent this image, if possible, otherwise null 247 */ 248 @Nullable 249 public Date getDateSent() 250 { 251 return getDate(TAG_DATE_SENT, TAG_TIME_SENT); 252 } 253 254 /** 255 * Parses the Release Date tag and the Release Time tag to obtain a single Date object representing the 256 * date and time when this image was released. 257 * @return A Date object representing when this image was released, if possible, otherwise null 258 */ 259 @Nullable 260 public Date getReleaseDate() 261 { 262 return getDate(TAG_RELEASE_DATE, TAG_RELEASE_TIME); 263 } 264 265 /** 266 * Parses the Expiration Date tag and the Expiration Time tag to obtain a single Date object representing 267 * that this image should not used after this date and time. 268 * @return A Date object representing when this image was released, if possible, otherwise null 269 */ 270 @Nullable 271 public Date getExpirationDate() 272 { 273 return getDate(TAG_EXPIRATION_DATE, TAG_EXPIRATION_TIME); 274 } 275 276 /** 277 * Parses the Date Created tag and the Time Created tag to obtain a single Date object representing the 278 * date and time when this image was captured. 279 * @return A Date object representing when this image was captured, if possible, otherwise null 280 */ 281 @Nullable 282 public Date getDateCreated() 283 { 284 return getDate(TAG_DATE_CREATED, TAG_TIME_CREATED); 285 } 286 287 /** 288 * Parses the Digital Date Created tag and the Digital Time Created tag to obtain a single Date object 289 * representing the date and time when the digital representation of this image was created. 290 * @return A Date object representing when the digital representation of this image was created, 291 * if possible, otherwise null 292 */ 293 @Nullable 294 public Date getDigitalDateCreated() 295 { 296 return getDate(TAG_DIGITAL_DATE_CREATED, TAG_DIGITAL_TIME_CREATED); 297 } 298 299 @Nullable 300 private Date getDate(int dateTagType, int timeTagType) 301 { 302 String date = getString(dateTagType); 303 String time = getString(timeTagType); 304 305 if (date == null) 306 return null; 307 if (time == null) 308 return null; 309 310 try { 311 DateFormat parser = new SimpleDateFormat("yyyyMMddHHmmssZ"); 312 return parser.parse(date + time); 313 } catch (ParseException e) { 314 return null; 315 } 316 } 238 317 }
Note:
See TracChangeset
for help on using the changeset viewer.