Skip to content

Commit ae49104

Browse files
Remove StringBuilder in Logback TimestampConverter (#97)
* Changed from StringBuilder to String Since we are appending only once, String.valueOf(timestamp) will suffice.
1 parent a029772 commit ae49104

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

cf-java-logging-support-logback/src/main/java/com/sap/hcp/cf/logback/converter/TimestampConverter.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ public class TimestampConverter extends ClassicConverter {
1616

1717
@Override
1818
public String convert(ILoggingEvent event) {
19-
StringBuilder appendTo = new StringBuilder();
20-
Instant now = Instant.now();
21-
long timestamp = now.getEpochSecond() * 1_000_000_000L + now.getNano();
22-
appendTo.append(timestamp);
23-
return appendTo.toString();
19+
Instant now = Instant.now();
20+
long timestamp = now.getEpochSecond() * 1_000_000_000L + now.getNano();
21+
return String.valueOf(timestamp);
2422
}
2523

2624
@Override

0 commit comments

Comments
 (0)