<i18n dev> Integrated: 8300818: Reduce complexity of padding with DateTimeFormatter
Sergey Tsypanov
stsypanov at openjdk.org
Mon May 1 18:41:49 UTC 2023
On Sat, 21 Jan 2023 21:01:48 GMT, Sergey Tsypanov <stsypanov at openjdk.org> wrote:
> Currently it's O(n) - we do `n` shifts of bytes within `StringBuilder`. This can be reduced to O(1) improving the code like:
>
> DateTimeFormatter dtf = new DateTimeFormatterBuilder()
> .appendLiteral("Date:")
> .padNext(20, ' ')
> .append(DateTimeFormatter.ISO_DATE)
> .toFormatter();
> String text = dtf.format(LocalDateTime.now());
This pull request has now been integrated.
Changeset: 561ec9c5
Author: Sergey Tsypanov <stsypanov at openjdk.org>
Committer: Roger Riggs <rriggs at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/561ec9c5a06e5baeb0cf72463d14d1d720facb13
Stats: 84 lines in 2 files changed: 83 ins; 0 del; 1 mod
8300818: Reduce complexity of padding with DateTimeFormatter
Reviewed-by: redestad, rriggs
-------------
PR: https://git.openjdk.org/jdk/pull/12131
More information about the i18n-dev
mailing list