Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use DateTimeFormatter.formatTo to directly append to StringBuilder #2515

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ private static boolean appendDate(final Object o, final StringBuilder str) {
if (!(o instanceof Date)) {
return false;
}
str.append(DATE_FORMATTER.format(((Date) o).toInstant()));
DATE_FORMATTER.formatTo(((Date) o).toInstant(), str);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ public Throwable getThrowable() {
@SuppressWarnings("DefaultCharset")
public String getFormattedStatus() {
final StringBuilder sb = new StringBuilder();
final String formattedInstant =
instantFormatter != null ? instantFormatter.format(instant) : instant.toString();
sb.append(formattedInstant);
// DateTimeFormatter.ISO_INSTANT is the default used in instant.toString()
DateTimeFormatter formatterToUse = instantFormatter != null ? instantFormatter : DateTimeFormatter.ISO_INSTANT;
formatterToUse.formatTo(instant, sb);
sb.append(SPACE);
sb.append(getThreadName());
sb.append(SPACE);
Expand Down
Loading