java.lang.Object
net.i2p.time.BuildTime
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
FieldsModifier and TypeFieldDescriptionprivate static final longWhen this build was made.private static final longOldest time a build could plausibly have happened.private static final longNewest time a build could plausibly have happened.private static final StringUpdate this periodically, and keep EARLIEST_LONG in sync with it.private static final longLower bound for a sane build date, 2025-01-02 00:00 UTC.private static final longTwenty-five years, in ms.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionprivate static Attributesattributes(File f) Reads a file's timestamps.static longThe build date fori2p.jar.private static longgetBuildTime(SimpleDateFormat fmt, String jar) Won't be available on Android or on any builds not using our build.xml.static longThe earliest it could possibly be right now.static longThe latest it could possibly be right now.static voidRun the BuildTime command-line utility.
Field Details
_buildTime
private static final long _buildTimeWhen this build was made._earliestTime
private static final long _earliestTimeOldest time a build could plausibly have happened._latestTime
private static final long _latestTimeNewest time a build could plausibly have happened.YEARS_25
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_LONGLower 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 fori2p.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
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 attributejar- the jar to read, relative to the lib directory, e.g. router.jar- Returns:
- 0 if unknown
attributes
Reads a file's timestamps.- Parameters:
f- the file to stat- Returns:
- its attributes, null if it cannot be read
main
Run the BuildTime command-line utility.- Parameters:
args- ignored; this utility takes no command-line arguments