commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kristian Rosenvold <>
Subject Re: [lang] LANG-1247: FastDatePrinter generates Date objects wastefully closes #168
Date Wed, 06 Jul 2016 06:19:38 GMT
2016-07-05 22:44 GMT+02:00  <>:
> LANG-1247: FastDatePrinter generates Date objects wastefully
> closes #168
>      public StringBuffer format(final long millis, final StringBuffer buf) {
> -        return format(new Date(millis), buf);
> +        final Calendar c = newCalendar();
> +        c.setTimeInMillis(millis);
> +        return applyRules(c, buf);

Arguably I might be a few years behind on developments regarding
java.lang.Calendar within the JDK, but from previous experience the
Calendar class is about as inefficient as things get, and anything
touching the calendar sprays your heap with objects. As far as I can
see, this just seems to be swapping around object allocation, probably
to the worse (instead of one visible object allocation within
commons-lang you're creating a fair bit of com.sun allocations as far
as I know)

I'd really like to see som evidence that this is an improvement, if
nothing else to enlighten me :)


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message