Source:
<code>public void testGetSetDateTime() throws IOException { final long expectedDatetimeValue = 1454059947000L; final long expectedDatetimeOffsetValue = 32400000L; final String dateTimeValue = "2017:02:02 22:22:22"; final String dateTimeOriginalValue = "2017:01:01 11:11:11"; File imageFile = new File( Environment.getExternalStorageDirectory(), JPEG_WITH_EXIF_BYTE_ORDER_II); ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath()); assertEquals(expectedDatetimeValue, <START> exif.getDateTime()); <END> exif.setAttribute(ExifInterface.TAG_DATETIME, dateTimeValue); exif.setAttribute(ExifInterface.TAG_DATETIME_ORIGINAL, dateTimeOriginalValue); exif.saveAttributes(); exif = new ExifInterface(imageFile.getAbsolutePath()); assertEquals(dateTimeValue, exif.getAttribute(ExifInterface.TAG_DATETIME)); assertEquals(dateTimeOriginalValue, exif.getAttribute(ExifInterface.TAG_DATETIME_ORIGINAL)); exif.setAttribute(ExifInterface.TAG_DATETIME, null); exif.saveAttributes(); exif = new ExifInterface(imageFile.getAbsolutePath()); assertEquals(dateTimeOriginalValue, exif.getAttribute(ExifInterface.TAG_DATETIME)); long currentTimeStamp = System.currentTimeMillis(); exif.setDateTime(currentTimeStamp); exif.saveAttributes(); exif = new ExifInterface(imageFile.getAbsolutePath()); assertEquals(currentTimeStamp - expectedDatetimeOffsetValue, exif.getDateTime()); }</code><technical_language>test getDateTimeDigitized, getDateTimeOriginal well</technical_language>

Target:
public void testGetSetDateTime() throws IOException { final long expectedDatetimeValue = 1454059947000L; final long expectedDatetimeOffsetLongValue = 32400000L; final String expectedDatetimeOffsetStringValue = "+09:00"; final String dateTimeValue = "2017:02:02 22:22:22"; final String dateTimeOriginalValue = "2017:01:01 11:11:11"; File imageFile = getFileFromExternalDir(JPEG_WITH_DATETIME_TAG); ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath()); assertEquals(expectedDatetimeValue, exif.getDateTime()); assertEquals(expectedDatetimeValue, exif.getDateTimeOriginal()); assertEquals(expectedDatetimeValue, exif.getDateTimeDigitized()); assertEquals(expectedDatetimeOffsetStringValue, exif.getAttribute(ExifInterface.TAG_OFFSET_TIME)); assertEquals(expectedDatetimeOffsetStringValue, exif.getAttribute(ExifInterface.TAG_OFFSET_TIME_ORIGINAL)); assertEquals(expectedDatetimeOffsetStringValue, exif.getAttribute(ExifInterface.TAG_OFFSET_TIME_DIGITIZED)); exif.setAttribute(ExifInterface.TAG_DATETIME, dateTimeValue); exif.setAttribute(ExifInterface.TAG_DATETIME_ORIGINAL, dateTimeOriginalValue); exif.saveAttributes(); exif = new ExifInterface(imageFile.getAbsolutePath()); assertEquals(dateTimeValue, exif.getAttribute(ExifInterface.TAG_DATETIME)); assertEquals(dateTimeOriginalValue, exif.getAttribute(ExifInterface.TAG_DATETIME_ORIGINAL)); exif.setAttribute(ExifInterface.TAG_DATETIME, null); exif.saveAttributes(); exif = new ExifInterface(imageFile.getAbsolutePath()); assertEquals(dateTimeOriginalValue, exif.getAttribute(ExifInterface.TAG_DATETIME)); long currentTimeStamp = System.currentTimeMillis(); exif.setDateTime(currentTimeStamp); exif.saveAttributes(); exif = new ExifInterface(imageFile.getAbsolutePath()); assertEquals(currentTimeStamp - expectedDatetimeOffsetLongValue, exif.getDateTime()); }