On Wed, 19 Nov 2025 00:42:03 GMT, Nir Lisker <[email protected]> wrote:

>> modules/javafx.base/src/main/java/javafx/util/StringConverter.java line 38:
>> 
>>> 36: /// - Except for `DefaultStringConverter`, formatting `null` returns an 
>>> empty string, otherwise the type's `toString` is
>>> 37: /// used if it is suitable; parsing `null` or an empty string returns 
>>> `null`.
>>> 38: /// - Immutable (the same converter can be reused).
>> 
>> Is this true? 
>> I recall some formatters having a state, but I don't remember which...
>
> Some do, but that state is immutable. Converters build a formatter/parser on 
> construction (if at all needed) and use it for the duration of their 
> existence. There are some deprecations that we need to do regarding 
> inspecting the internal state.

This is what `DateFormat` javadoc says:


Synchronization
Date formats are not synchronized. It is recommended to create separate format 
instances for each thread. If multiple threads access a format concurrently, it 
must be synchronized externally.


As long as the `DateTimeStringConverter` is used only in the context of the FX 
application thread, we should be fine.  But can we guarantee that the 
application code does not try to call it from other threads?

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1880#discussion_r2542594368

Reply via email to