RFR: 8316235: Optimization for DateTimeFormatter::format

温绍锦 duke at openjdk.org
Thu Sep 14 02:21:13 UTC 2023


In many scenarios, DateTimeFormatter::format is a slower operation.  

For example, the following business scenarios
1. The json library gson/jackson/[fastjson2](https://github.com/alibaba/fastjson2) formats Instant/LocalDate/LocalTime/LocalDateTime/ZonedDateTim into strings.
2. In data integration scenarios, for projects like  [datax](https://github.com/alibaba/datax)/[canal](https://github.com/alibaba/canal), if the input type is Date/Instant and the output type is String, formatting is required.

This PR provides format performance optimization for commonly used date patterns.

ISO_INSTANT
ISO_LOCAL_TIME
ISO_LOCAL_DATE
ISO_LOCAL_DATETIME
HH:mm:ss
HH:mm:ss.SSS
yyyy-MM-dd
yyyy-MM-dd HH:mm:ss
yyyy-MM-dd'T'HH:mm:ss
yyyy-MM-dd HH:mm:ss.SSS
yyyy-MM-dd'T'HH:mm:ss.SSS

-------------

Commit messages:
 - fix format LocalTime/LocalDateTime use utc
 - fix format ZonedDateTime & OffsetDateTime & OffsetTime use utc
 - sealed class CompositePrinterParser
 - use Pattern Matching switch
 - remove LocalTimePrinterParser::format support Instant
 - optimization support pattern 'yyyy-MM-dd HH:mm:ss.SSS'
 - remove digit_k
 - optimize DateTimeFormatter::format
 - fix InstantPrinterParser miss nanos
 - remove TimeCompositePrinterParser, fix build error
 - ... and 1 more: https://git.openjdk.org/jdk/compare/e0845163...564ae18b

Changes: https://git.openjdk.org/jdk/pull/15722/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15722&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8316235
  Stats: 418 lines in 6 files changed: 341 ins; 51 del; 26 mod
  Patch: https://git.openjdk.org/jdk/pull/15722.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/15722/head:pull/15722

PR: https://git.openjdk.org/jdk/pull/15722


More information about the security-dev mailing list