mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Sonar suggested using the Java 8 method Instant.truncatedTo, as it is faster than DateUtils.truncate. However it has different handling of TimeZones, and the old version of this code only works when the server is set to use UTC. In order to fix this 'properly' we need code like: date = (date == null ? new Date() : date); return Date.from(date.toInstant().atZone(ZoneId.systemDefault()).truncatedTo(ChronoUnit.DAYS).toInstant()); which is significantly less readable than just using DateUtils.truncate. Given that this code hasn't ever been highlighted by our profiling, I suggest we revert back to the older code.