8337168: Optimize LocalDateTime.toString

Reviewed-by: liach, naoto
This commit is contained in:
Shaojin Wen 2024-07-26 12:10:21 +00:00
parent 374fca0fcb
commit 5ff7c57f9f
3 changed files with 30 additions and 10 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -1965,7 +1965,11 @@ public final class LocalDateTime
*/
@Override
public String toString() {
return date.toString() + 'T' + time.toString();
var buf = new StringBuilder(29);
date.formatTo(buf);
buf.append('T');
time.formatTo(buf);
return buf.toString();
}
//-----------------------------------------------------------------------