Can I get the time of compilation of a java class from withing itself?

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

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

Is this possible?

Jon Skeet
people
quotationmark

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.)

people

See more on this question at Stackoverflow