[threeten-dev] Default Method in ChronoLocalDate and usage in LocalDate Question

James Gough jpgough at gmail.com
Tue Jan 14 16:58:52 PST 2014


Hi,

This is a question about default methods in java.time in 1.8.0-ea. In
ChronoLocalDate interface the format method is a default method:

    default String format(DateTimeFormatter formatter) {
        Objects.requireNonNull(formatter, "formatter");
        return formatter.format(this);
    }

In LocalDate this default method is overridden with:

    @Override  // override for Javadoc and performance
    public String format(DateTimeFormatter formatter) {
        Objects.requireNonNull(formatter, "formatter");
        return formatter.format(this);
    }

What is the performance benefit of doing this? As it's the same code why
would we not just use the default method implementation?

Regards,
Jim


More information about the threeten-dev mailing list