Time: Fix crashes on old Androids (ticket #1976)

This commit is contained in:
zzz
2017-03-27 14:12:42 +00:00
parent b503f03bd6
commit c1991241e4

View File

@ -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");