File Dates Comparison
From Java Example Source Code
Contents |
[edit] Overview - File Dates Comparison
This Java program introduce file dates comparison.
[edit] Java Source Code
- Package: example.calendardate
- File: CompareFileDates.java
package example.calendardate; import java.io.File; public class CompareFileDates { public static void main(String[] args) { // Get the timestamp from file 1 String f1 = "run.bat"; long d1 = new File(f1).lastModified(); // Get the timestamp from file 2 String f2 = "build.xml"; long d2 = new File(f2).lastModified(); String relation; if (d1 == d2) relation = "the same age as"; else if (d1 < d2) relation = "older than"; else relation = "newer than"; System.out.println(f1 + " is " + relation + ' ' + f2); } }
[edit] What Result You Can Get
Run the program, you will get:
run.bat is the same age as build.xml
[edit] Required External Libraries and/or Files for this Java Example
Need nothing.
[edit] How to Run this Java Example Program
We recommend running this Java example program with Eclipse.
For assistance in working with Eclipse, please see How to Run Java Program with Eclipse.
It's fairly easy.
[edit] Question & Answer
Any question?
Click edit and post your question or answer here.
