Ignore:
Timestamp:
2016-08-20T20:58:03+02:00 (8 years ago)
Author:
Don-vip
Message:

update to metadata-extractor 2.9.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/drew/metadata/iptc/IptcDirectory.java

    r8132 r10862  
    11/*
    2  * Copyright 2002-2015 Drew Noakes
     2 * Copyright 2002-2016 Drew Noakes
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
     
    2525import com.drew.metadata.Directory;
    2626
     27import java.text.DateFormat;
     28import java.text.ParseException;
     29import java.text.SimpleDateFormat;
    2730import java.util.Arrays;
     31import java.util.Date;
    2832import java.util.HashMap;
    2933import java.util.List;
     
    231235    public List<String> getKeywords()
    232236    {
    233         final String[] array = getStringArray(IptcDirectory.TAG_KEYWORDS);
     237        final String[] array = getStringArray(TAG_KEYWORDS);
    234238        if (array==null)
    235239            return null;
    236240        return Arrays.asList(array);
    237241    }
     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    }
    238317}
Note: See TracChangeset for help on using the changeset viewer.