From 1c99dd8b1824d508236b2919897a5fe5e6fae6d7 Mon Sep 17 00:00:00 2001 From: terry-norbraten <tnorb@comcast.net> Date: Fri, 30 Jul 2021 11:23:52 -0700 Subject: [PATCH] [Terry N.] Need the cast to int. Breaks too many other things downstream esp, using reflection to return a timestamp from the PduFactory --- .../edu/nps/moves/dis7/pdus/DisTime.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src-generated/edu/nps/moves/dis7/pdus/DisTime.java b/src-generated/edu/nps/moves/dis7/pdus/DisTime.java index 84d9bd0733..ffb9cf1843 100644 --- a/src-generated/edu/nps/moves/dis7/pdus/DisTime.java +++ b/src-generated/edu/nps/moves/dis7/pdus/DisTime.java @@ -63,8 +63,10 @@ public class DisTime { /** mask for absolute timestamps */ public static final int ABSOLUTE_TIMESTAMP_MASK = 0x00000001; + /** mask for relative timestamps */ public static final int RELATIVE_TIMESTAMP_MASK = 0xfffffffe; + /** calendar instance */ protected GregorianCalendar calendar; @@ -83,7 +85,8 @@ public class DisTime return disTime; } -*/ + */ + public DisTime() { calendar = new GregorianCalendar(); @@ -95,6 +98,7 @@ public class DisTime * @return integer DIS time units since the start of the hour. */ private int getDisTimeUnitsSinceTopOfHour() { + // set calendar object to current time long currentTime = System.currentTimeMillis(); // UTC milliseconds since 1970 calendar.setTimeInMillis(currentTime); @@ -124,7 +128,6 @@ public class DisTime * Fix to bitshift by mvormelch. * @return DIS time units, get absolute timestamp */ - public int getDisAbsoluteTimestamp() { int val = this.getDisTimeUnitsSinceTopOfHour(); val = (val << 1) | ABSOLUTE_TIMESTAMP_MASK; // always flip the lsb to 1 @@ -148,7 +151,7 @@ public class DisTime * as long as you're not working on New Year's Eve. * @return a timestamp in hundredths of a second since the start of the year */ - public long getNpsTimestamp() { + public int getNpsTimestamp() { // set calendar object to current time long currentTime = System.currentTimeMillis(); // UTC milliseconds since 1970 calendar.setTimeInMillis(currentTime); @@ -166,7 +169,7 @@ public class DisTime long diff = currentTime - startOfYear; diff /= 10; // milliseconds to hundredths of a second - return diff; + return (int) diff; } /** @@ -186,11 +189,12 @@ public class DisTime * Consult the Wikipedia page on <a href="https://en.wikipedia.org/wiki/Unix_time">Unix time</a> for the gory details * @return seconds since 1970 */ - public long getUnixTimestamp() { + public int getUnixTimestamp() { long t = System.currentTimeMillis(); t /= 1000l; // NB: integer division, convert milliseconds to seconds - return t; + return (int) t; } + /** * Convert timestamp value to string for logging and diagnostics * @param timeStamp value in milliseconds -- GitLab