File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
vaadin-editable-label/src/main/java/software/xdev/vaadin/editable_label/predefined Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 1+ # 2.1.3
2+ * Cache ` DateTimeFormatter ` if possible
3+ * Updated dependencies
4+
15# 2.1.2
26* Migrated deployment to _ Sonatype Maven Central Portal_ [ #155 ] ( https://github.com/xdev-software/standard-maven-template/issues/155 )
37* Updated dependencies
Original file line number Diff line number Diff line change 1717
1818import java .time .LocalDate ;
1919import java .time .format .DateTimeFormatter ;
20+ import java .util .Collections ;
21+ import java .util .Map ;
22+ import java .util .WeakHashMap ;
2023import java .util .function .Consumer ;
2124
2225import com .vaadin .flow .component .datepicker .DatePicker ;
3336public class EditableLabelDatePicker
3437 extends AbstractEditableLabel <EditableLabelDatePicker , DatePicker , LocalDate >
3538{
39+ protected static final Map <String , DateTimeFormatter > CACHE_DTF = Collections .synchronizedMap (new WeakHashMap <>());
40+
3641 public EditableLabelDatePicker ()
3742 {
3843 this (new DatePicker ());
@@ -60,7 +65,9 @@ public EditableLabelDatePicker withTryUseI18NFormat()
6065 final DatePicker .DatePickerI18n i18n = this .editor .getI18n ();
6166 if (i18n != null && !i18n .getDateFormats ().isEmpty ())
6267 {
63- this .withLabelGenerator (DateTimeFormatter .ofPattern (i18n .getDateFormats ().get (0 ))::format );
68+ final DateTimeFormatter dtf =
69+ CACHE_DTF .computeIfAbsent (i18n .getDateFormats ().get (0 ), DateTimeFormatter ::ofPattern );
70+ this .withLabelGenerator (dtf ::format );
6471 }
6572 return this .self ();
6673 }
You can’t perform that action at this time.
0 commit comments