mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8337832: Optimize datetime toString
Reviewed-by: scolebourne, liach, naoto
This commit is contained in:
parent
b1b4cd429a
commit
449ca2c3c1
4 changed files with 31 additions and 9 deletions
|
@ -1966,10 +1966,17 @@ public final class LocalDateTime
|
|||
@Override
|
||||
public String toString() {
|
||||
var buf = new StringBuilder(29);
|
||||
formatTo(buf);
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the toString result to the given buf, avoiding extra string allocations.
|
||||
*/
|
||||
void formatTo(StringBuilder buf) {
|
||||
date.formatTo(buf);
|
||||
buf.append('T');
|
||||
time.formatTo(buf);
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue