mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Revert changes to getStartOfDay.
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.
This commit is contained in:
@@ -37,7 +37,6 @@ import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Serializable;
|
||||
import java.io.Writer;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
@@ -1140,8 +1139,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
|
||||
*/
|
||||
protected Date getStartOfDay(Date date)
|
||||
{
|
||||
date = (date == null ? new Date() : date);
|
||||
return Date.from(date.toInstant().truncatedTo(ChronoUnit.DAYS));
|
||||
return DateUtils.truncate(date == null ? new Date() : date, Calendar.DATE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user