FULL PRODUCT VERSION :
C:\Users\truscotr>java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows 7 64bit
EXTRA RELEVANT SYSTEM CONFIGURATION :
Couldn't find an area for Java time component, please forward to appropriate area
A DESCRIPTION OF THE PROBLEM :
When the time exactly hits 00, the ZoneDateTime.now() chops the 00 seconds. 01-59 is unaffected
Note: The counterpart to this Instant.now() handles "00" correctly
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
while(0==BigDecimal.ZERO.intValue()) { // trick it
msgDateTime = ZonedDateTime.now().truncatedTo(ChronoUnit.SECONDS).toString();
String msgDateTimeCompact1 = msgDateTime!=null ?StringUtils.substringBefore(msgDateTime, "+") : "";
System.out.println(msgDateTimeCompact1);
if (Utils.sizeAfter(msgDateTimeCompact1,"T") == 5) { logger.warn("Rectified. Adding seconds to {}",msgDateTimeCompact1.toString()); msgDateTimeCompact1+=Utils.ZERO_SEC; }
System.out.println(msgDateTimeCompact1);
System.out.println(chop(Instant.now().truncatedTo(ChronoUnit.SECONDS).toString()));
System.out.println("---");
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Top line is ZonedDateTime (unfixed)
2nd line is my patch to add zeroes
3rd line is Instant Now (which always works)
2017-12-08T10:37:59
2017-12-08T10:37:59
2017-12-07T23:37:59
---
2017-12-08T10:37:59
2017-12-08T10:37:59
2017-12-07T23:37:59
---
2017-12-08T10:38
2017-12-08T10:38:00
2017-12-07T23:38:00
---
2017-12-08T10:38
2017-12-08T10:38:00
2017-12-07T23:38:00
---
2017-12-08T10:38
2017-12-08T10:38:00
2017-12-07T23:38:00
---
2017-12-08T10:38:01
2017-12-08T10:38:01
2017-12-07T23:38:01
---
2017-12-08T10:38:01
2017-12-08T10:38:01
2017-12-07T23:38:01
---
ACTUAL -
See above
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
while(0==BigDecimal.ZERO.intValue()) { // trick it
msgDateTime = ZonedDateTime.now().truncatedTo(ChronoUnit.SECONDS).toString();
String msgDateTimeCompact1 = msgDateTime!=null ?StringUtils.substringBefore(msgDateTime, "+") : "";
System.out.println(msgDateTimeCompact1);
if (Utils.sizeAfter(msgDateTimeCompact1,"T") == 5) { logger.warn("Rectified. Adding seconds to {}",msgDateTimeCompact1.toString()); msgDateTimeCompact1+=Utils.ZERO_SEC; }
System.out.println(msgDateTimeCompact1);
System.out.println(chop(Instant.now().truncatedTo(ChronoUnit.SECONDS).toString()));
System.out.println("---");
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
In the code above
C:\Users\truscotr>java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows 7 64bit
EXTRA RELEVANT SYSTEM CONFIGURATION :
Couldn't find an area for Java time component, please forward to appropriate area
A DESCRIPTION OF THE PROBLEM :
When the time exactly hits 00, the ZoneDateTime.now() chops the 00 seconds. 01-59 is unaffected
Note: The counterpart to this Instant.now() handles "00" correctly
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
while(0==BigDecimal.ZERO.intValue()) { // trick it
msgDateTime = ZonedDateTime.now().truncatedTo(ChronoUnit.SECONDS).toString();
String msgDateTimeCompact1 = msgDateTime!=null ?StringUtils.substringBefore(msgDateTime, "+") : "";
System.out.println(msgDateTimeCompact1);
if (Utils.sizeAfter(msgDateTimeCompact1,"T") == 5) { logger.warn("Rectified. Adding seconds to {}",msgDateTimeCompact1.toString()); msgDateTimeCompact1+=Utils.ZERO_SEC; }
System.out.println(msgDateTimeCompact1);
System.out.println(chop(Instant.now().truncatedTo(ChronoUnit.SECONDS).toString()));
System.out.println("---");
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Top line is ZonedDateTime (unfixed)
2nd line is my patch to add zeroes
3rd line is Instant Now (which always works)
2017-12-08T10:37:59
2017-12-08T10:37:59
2017-12-07T23:37:59
---
2017-12-08T10:37:59
2017-12-08T10:37:59
2017-12-07T23:37:59
---
2017-12-08T10:38
2017-12-08T10:38:00
2017-12-07T23:38:00
---
2017-12-08T10:38
2017-12-08T10:38:00
2017-12-07T23:38:00
---
2017-12-08T10:38
2017-12-08T10:38:00
2017-12-07T23:38:00
---
2017-12-08T10:38:01
2017-12-08T10:38:01
2017-12-07T23:38:01
---
2017-12-08T10:38:01
2017-12-08T10:38:01
2017-12-07T23:38:01
---
ACTUAL -
See above
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
while(0==BigDecimal.ZERO.intValue()) { // trick it
msgDateTime = ZonedDateTime.now().truncatedTo(ChronoUnit.SECONDS).toString();
String msgDateTimeCompact1 = msgDateTime!=null ?StringUtils.substringBefore(msgDateTime, "+") : "";
System.out.println(msgDateTimeCompact1);
if (Utils.sizeAfter(msgDateTimeCompact1,"T") == 5) { logger.warn("Rectified. Adding seconds to {}",msgDateTimeCompact1.toString()); msgDateTimeCompact1+=Utils.ZERO_SEC; }
System.out.println(msgDateTimeCompact1);
System.out.println(chop(Instant.now().truncatedTo(ChronoUnit.SECONDS).toString()));
System.out.println("---");
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
In the code above