diff options
author | aclement <aclement> | 2006-08-25 12:41:38 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-08-25 12:41:38 +0000 |
commit | 40cf61076994bf2dd6f0397b1bd0287ed546a75b (patch) | |
tree | 99e2de64e95686d07ec08c6e2ee9bfe9ce15e28f /bridge | |
parent | b394aa711917bc4330bccbb65032171a12fcb8fa (diff) | |
download | aspectj-40cf61076994bf2dd6f0397b1bd0287ed546a75b.tar.gz aspectj-40cf61076994bf2dd6f0397b1bd0287ed546a75b.zip |
fix for 155213: made using date formatter lazy.
Diffstat (limited to 'bridge')
-rw-r--r-- | bridge/src/org/aspectj/bridge/Version.java | 27 | ||||
-rw-r--r-- | bridge/testsrc/org/aspectj/bridge/VersionTest.java | 2 |
2 files changed, 16 insertions, 13 deletions
diff --git a/bridge/src/org/aspectj/bridge/Version.java b/bridge/src/org/aspectj/bridge/Version.java index c08d24f60..028cdd96d 100644 --- a/bridge/src/org/aspectj/bridge/Version.java +++ b/bridge/src/org/aspectj/bridge/Version.java @@ -43,22 +43,25 @@ public class Version { * time in seconds-since-... format, used by programmatic clients. * (if DEVELOPMENT version, NOTIME) */ - public static final long time; + private static long time = -1; // -1 = uninitialized /** format used by build script to set time_text */ public static final String SIMPLE_DATE_FORMAT = "EEEE MMM d, yyyy 'at' HH:mm:ss z"; - // if not DEVELOPMENT version, read time text using format used to set time - static { - long foundTime = NOTIME; - try { - SimpleDateFormat format = new SimpleDateFormat(SIMPLE_DATE_FORMAT); - ParsePosition pos = new ParsePosition(0); - Date date = format.parse(time_text, pos); - foundTime = date.getTime(); - } catch (Throwable t) { - } - time = foundTime; + public static long getTime() { + if (time==-1) { + long foundTime = NOTIME; + // if not DEVELOPMENT version, read time text using format used to set time + try { + SimpleDateFormat format = new SimpleDateFormat(SIMPLE_DATE_FORMAT); + ParsePosition pos = new ParsePosition(0); + Date date = format.parse(time_text, pos); + if (date!=null) foundTime = date.getTime(); + } catch (Throwable t) { + } + time = foundTime; + } + return time; } /** diff --git a/bridge/testsrc/org/aspectj/bridge/VersionTest.java b/bridge/testsrc/org/aspectj/bridge/VersionTest.java index 6339a1633..1da10675c 100644 --- a/bridge/testsrc/org/aspectj/bridge/VersionTest.java +++ b/bridge/testsrc/org/aspectj/bridge/VersionTest.java @@ -44,7 +44,7 @@ public class VersionTest extends TestCase { public void testVersion() { if (Version.time_text.equals("")) return; // dev build, we can only test this on the build server. - Date date = new Date(Version.time); + Date date = new Date(Version.getTime()); SimpleDateFormat format = new SimpleDateFormat(Version.SIMPLE_DATE_FORMAT, Locale.getDefault()); format.setTimeZone(TimeZone.getTimeZone("GMT")); String timeString = format.format(date); |