The use of the Instant class introduced in Java 8 to truncate a date can be significantly faster than the DateUtils class from Commons Lang.
public Date trunc(Date date) {
return DateUtils.truncate(date, Calendar.SECOND); // Noncompliant
}
public Date trunc(Date date) {
Instant instant = date.toInstant();
instant = instant.truncatedTo(ChronoUnit.SECONDS);
return Date.from(instant);
}