From c1991241e43d156415e04e9103fce0a76c46a1a0 Mon Sep 17 00:00:00 2001 From: zzz Date: Mon, 27 Mar 2017 14:12:42 +0000 Subject: [PATCH] Time: Fix crashes on old Androids (ticket #1976) --- core/java/src/net/i2p/time/BuildTime.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/core/java/src/net/i2p/time/BuildTime.java b/core/java/src/net/i2p/time/BuildTime.java index be47ce7a1c..7f126ed562 100644 --- a/core/java/src/net/i2p/time/BuildTime.java +++ b/core/java/src/net/i2p/time/BuildTime.java @@ -34,7 +34,10 @@ public class BuildTime { private static final long _latestTime; private static final long YEARS_25 = 25L*365*24*60*60*1000; /** update this periodically */ - private static final String EARLIEST = "2016-02-19 12:00:00 UTC"; + private static final String EARLIEST = "2017-03-27 12:00:00 UTC"; + // fallback if parse fails ticket #1976 + // date -d 201x-xx-xx +%s + private static final long EARLIEST_LONG = 1490587200 * 1000L; static { // this is the standard format of build.timestamp as set in the top-level build.xml @@ -45,12 +48,15 @@ public class BuildTime { try { Date date = fmt.parse(EARLIEST); if (date == null) - throw new RuntimeException("BuildTime FAIL"); - min = date.getTime(); + min = EARLIEST_LONG; + else + min = date.getTime(); } catch (ParseException pe) { System.out.println("BuildTime FAIL"); - pe.printStackTrace(); - throw new RuntimeException("BuildTime FAIL", pe); + // Old Android, ticket #1976 + //pe.printStackTrace(); + //throw new RuntimeException("BuildTime FAIL", pe); + min = EARLIEST_LONG; } long max = min + YEARS_25; long build = getBuildTime(fmt, "i2p.jar");