IBM Support

Java API lastModified() method of java.io.File class limitation on UNIX

Troubleshooting


Problem

The lastModified() method of File API provides only seconds precision whereas the API documentation claims that this method returns precision up to nanosecond.

Symptom

File adapters use the lastModified() method of java.io.File API to sort files by timestamp. However, this method returns only second precision for a file's last modified timestamp on UNIX. This is a limitation with all versions of JDK up to version 1.6.

The limitation has been documented at the following link: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6939260

Resolving The Problem

There is currently no resolution within JDK for this limitation. To workaround this limitation, use the alternate approach that is provided by the adapter, which is to sort files by the file name.

[{"Product":{"code":"SSMKUK","label":"WebSphere Adapters Family"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Adapter \u2013 Non-specific","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"}],"Version":"7.0.1;7.0;6.2;6.1","Edition":"","Line of Business":{"code":"","label":""}}]

Document Information

Modified date:
15 June 2018

UID

swg21446506