Get Last Modified Date of A Raster Image
Contents
[
Hide
]
This article demonstrates the usage of Aspose.Imaging for Java to get last modified date of an image. Aspose.Imaging APIs have exposed efficient & easy to use methods to achieve this goal.
Get Last Modified Date
Aspose.Imaging for Java has exposed the getModifyDate method of Image class to get the last modified date of an image from its metadata. getModifyDate method needs a Boolean value to get the modified date accordingly.
The steps to get last modified date are as simple as below:
- Load an image using the factory method Load exposed by Image class.
- Convert the image into RasterImage.
- Call the RasterImage.getModifyDate method by passing a Boolean true or false value.
The following code example demonstrates how to get last modified date of the image.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/Muhammad-Adnan-Ahmad/Aspose.Imaging-for-Java | |
String path = dataDir + "aspose-logo.jpg"; | |
com.aspose.imaging.RasterImage image = (com.aspose.imaging.RasterImage) Image.load(path); | |
try { | |
// gets the date from [FileInfo] | |
String modifyDate = image.getModifyDate(true).toString(); | |
System.out.format("Last modify date using FileInfo: %s\n", modifyDate); | |
// gets the date from XMP metadata of [FileInfo] as long as it's not | |
// default case | |
modifyDate = image.getModifyDate(false).toString(); | |
System.out.format("Last modify date using info from FileInfo and XMP metadata: %s\n", modifyDate); | |
} finally { | |
image.dispose(); | |
} |