Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60b432f7 authored by Marco Nelissen's avatar Marco Nelissen Committed by Android Git Automerger
Browse files

am 8a76cd6d: am 59984c79: am 2e2ac33e: Merge "Update ExifInterface.getDateTime...

am 8a76cd6d: am 59984c79: am 2e2ac33e: Merge "Update ExifInterface.getDateTime to support subseconds" into mnc-dev

* commit '8a76cd6d':
  Update ExifInterface.getDateTime to support subseconds
parents 71123f87 8a76cd6d
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -58,6 +58,11 @@ public class ExifInterface {
    /** Type is String. */
    public static final String TAG_ISO = "ISOSpeedRatings";

    /**
     * @hide
     */
    public static final String TAG_SUBSECTIME = "SubSecTime";

    /**
     * The altitude (in meters) based on the reference in TAG_GPS_ALTITUDE_REF.
     * Type is rational.
@@ -346,7 +351,7 @@ public class ExifInterface {
    }

    /**
     * Returns number of milliseconds since Jan. 1, 1970, midnight.
     * Returns number of milliseconds since Jan. 1, 1970, midnight local time.
     * Returns -1 if the date time information if not available.
     * @hide
     */
@@ -356,9 +361,24 @@ public class ExifInterface {

        ParsePosition pos = new ParsePosition(0);
        try {
            // The exif field is in local time. Parsing it as if it is UTC will yield time
            // since 1/1/1970 local time
            Date datetime = sFormatter.parse(dateTimeString, pos);
            if (datetime == null) return -1;
            return datetime.getTime();
            long msecs = datetime.getTime();

            String subSecs = mAttributes.get(TAG_SUBSECTIME);
            if (subSecs != null) {
                try {
                    long sub = Long.valueOf(subSecs);
                    while (sub > 1000) {
                        sub /= 10;
                    }
                    msecs += sub;
                } catch (NumberFormatException e) {
                }
            }
            return msecs;
        } catch (IllegalArgumentException ex) {
            return -1;
        }
@@ -375,7 +395,6 @@ public class ExifInterface {
        if (date == null || time == null) return -1;

        String dateTimeString = date + ' ' + time;
        if (dateTimeString == null) return -1;

        ParsePosition pos = new ParsePosition(0);
        try {