I've researched and tried numerous options to try and get this to work, but am not getting anywhere with this unfortunately.
What I am trying to do is set the Date Taken tag (Tag_DateTime) in a JPEG's Exif data from within an Android app. I already have working code to set the Latitude and Longitute tags, but cannot for the life of me get the Date taken tag to set.
Here is the code:
SimpleDateFormat fmt_Exif = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
try {
ExifInterface exif = new ExifInterface(filePhoto.getPath());
// Set and save the GPS and time data
exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, strLat);
exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, strLong);
exif.setAttribute(ExifInterface.TAG_DATETIME, fmt_Exif.format(locLatestLocation.getTime()));
exif.saveAttributes();
} catch (IOException e) {
e.printStackTrace();
}
- locLatestLocation - Location being used to get the time in milliseconds.
- fmt_Exif - SimpleDateFormat used to format the millisecond time into the correct format for the TAG_DateTime Exif tag.
- strLat & strLong - Populated elsewhere in the correct format to set the Latitude and Longitude tags.
I read in a post somewhere that the tag needs to be written in the milliseconds format, so have tried this too to no avail. In order to confirm my formatting with what is actually stored, I read and outputted the unformatted tag from a jpeg file which has the Date Taken tag, but the output is in exactly the same format as what I am writing to the tag and its still not working.
It might also be worth mentioning that I have looking into the Sanselan class to do this, and due to the complexity and lack of examples would much rather try and get my existing solution working before changing to a completely different one.
Has anyone managed to do this and if so what am I doing wrong??