java.lang.Object
net.i2p.time.BuildTime

public class BuildTimeextends Object
The build date as set in i2p.jar, and reasonable min and max values for the current time, to be used as sanity checks.

Idea taken from Chrome, which assumes any clock more than 2 days before or 1 year after the build date is bad.

Not maintained as a public API, not for use by plugins or applications.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final long
    When this build was made.
    private static final long
    Oldest time a build could plausibly have happened.
    private static final long
    Newest time a build could plausibly have happened.
    private static final String
    Update this periodically, and keep EARLIEST_LONG in sync with it.
    private static final long
    Lower bound for a sane build date, 2025-01-02 00:00 UTC.
    private static final long
    Twenty-five years, in ms.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Utility class, not intended for instantiation.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static Attributes
    Reads a file's timestamps.
    static long
    The build date for i2p.jar.
    private static long
    Won't be available on Android or on any builds not using our build.xml.
    static long
    The earliest it could possibly be right now.
    static long
    The latest it could possibly be right now.
    static void
    main(String[] args)
    Run the BuildTime command-line utility.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _buildTime

      private static final long _buildTime
      When this build was made.
    • _earliestTime

      private static final long _earliestTime
      Oldest time a build could plausibly have happened.
    • _latestTime

      private static final long _latestTime
      Newest time a build could plausibly have happened.
    • YEARS_25

      private static final long YEARS_25
      Twenty-five years, in ms.
      See Also:
    • EARLIEST

      private static final String EARLIEST
      Update this periodically, and keep EARLIEST_LONG in sync with it. A build older than this is reported as a strange build time.
      See Also:
    • EARLIEST_LONG

      private static final long EARLIEST_LONG
      Lower bound for a sane build date, 2025-01-02 00:00 UTC.
      See Also:
  • Constructor Details

    • BuildTime

      private BuildTime()
      Utility class, not intended for instantiation.
  • Method Details

    • getBuildTime

      public static long getBuildTime()
      The build date for i2p.jar.
      Returns:
      the earliest possible time if actual build date is unknown
    • getEarliestTime

      public static long getEarliestTime()
      The earliest it could possibly be right now. Latest of the build time minus a day, or a hardcoded time.
      Returns:
      the earliest build time in milliseconds since the epoch that could still be genuine
    • getLatestTime

      public static long getLatestTime()
      The latest it could possibly be right now. Hardcoded.
      Returns:
      the latest build time in milliseconds since the epoch that could still be genuine
    • getBuildTime

      private static long getBuildTime(SimpleDateFormat fmt, String jar)
      Won't be available on Android or on any builds not using our build.xml.
      Parameters:
      fmt - the format of the jar's Build-Date manifest attribute
      jar - the jar to read, relative to the lib directory, e.g. router.jar
      Returns:
      0 if unknown
    • attributes

      private static Attributes attributes(File f)
      Reads a file's timestamps.
      Parameters:
      f - the file to stat
      Returns:
      its attributes, null if it cannot be read
    • main

      public static void main(String[] args)
      Run the BuildTime command-line utility.
      Parameters:
      args - ignored; this utility takes no command-line arguments