2

I'd like to print the time of compilation of a class.

class Test {
  public Test() {
    System.out.println("Compiled:" + getCompilationTimestamp());
  }
}

Is this possible?

Roger C S Wernersson
  • 6,362
  • 6
  • 34
  • 45

2 Answers2

3

Looking at the class file format, I don't believe that information is stored anywhere - so the answer would be "no".

If you're building your classes into a jar file, you might want to include a metadata file which specifies this information. (I don't think there's anything suitable in the manifest file format, but I could be wrong.)

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
0

Any file has a last-modified timestamp: File.lastModified(); For a compiled File i see no practical scenario where this is not equal to the creation time.

user2504380
  • 535
  • 4
  • 12