summaryrefslogtreecommitdiffstats
path: root/uitest/src/main
diff options
context:
space:
mode:
authorAhmed Ashour <asashour@yahoo.com>2017-09-28 11:37:32 +0200
committerHenri Sara <henri.sara@gmail.com>2017-09-28 12:37:32 +0300
commitc520767bf156c54a9d1a9f69f0aa78bc3b835b3f (patch)
tree208c6d8679708a6cc9e8b425d86fe10f2abeedc9 /uitest/src/main
parent131601de3693655387313e47e887f593c32fa625 (diff)
downloadvaadin-framework-c520767bf156c54a9d1a9f69f0aa78bc3b835b3f.tar.gz
vaadin-framework-c520767bf156c54a9d1a9f69f0aa78bc3b835b3f.zip
Handle 'z' (timezone) in AbstractDateField.setDateFormat() (#8844)
Diffstat (limited to 'uitest/src/main')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/datefield/DateTimeFieldZoneId.java78
1 files changed, 78 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/DateTimeFieldZoneId.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateTimeFieldZoneId.java
new file mode 100644
index 0000000000..cbdbc23ec1
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateTimeFieldZoneId.java
@@ -0,0 +1,78 @@
+package com.vaadin.tests.components.datefield;
+
+import java.time.LocalDateTime;
+import java.time.Month;
+import java.time.ZoneId;
+import java.util.Locale;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.stream.Stream;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.DateTimeField;
+import com.vaadin.ui.TextField;
+
+public class DateTimeFieldZoneId extends AbstractTestUI {
+
+ static final String ZONE_ID = "zoneId";
+ static final String LOCALE_ID = "localeId";
+ static final String PATTERN_ID = "patternId";
+
+ static final LocalDateTime INITIAL_DATE_TIME = LocalDateTime.of(2017,
+ Month.JANUARY, 1, 0, 0);
+ private static final String FORMAT_PATTERN = "dd MMM yyyy - hh:mm:ss a z";
+
+ @Override
+ protected String getTestDescription() {
+ return "DateTimeField to correctly show time zone name";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8844;
+ }
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final ComboBox<String> zoneIdComboBox = new ComboBox<>();
+ zoneIdComboBox.setId(ZONE_ID);
+ Set<String> zoneIdSet = new TreeSet<>(ZoneId.getAvailableZoneIds());
+ zoneIdComboBox.setItems(zoneIdSet);
+ addComponent(zoneIdComboBox);
+
+ final ComboBox<Locale> localeIdComboBox = new ComboBox<>();
+ localeIdComboBox.setId(LOCALE_ID);
+ Stream<Locale> localeStream = Stream.of(Locale.getAvailableLocales())
+ .sorted((l1, l2) -> l1.toString().compareTo(l2.toString()));
+ localeIdComboBox.setItems(localeStream);
+ addComponent(localeIdComboBox);
+
+ final TextField patternTextField = new TextField();
+ patternTextField.setId(PATTERN_ID);
+ patternTextField.setValue(FORMAT_PATTERN);
+ addComponent(patternTextField);
+
+ final DateTimeField dateTimeField = new DateTimeField();
+ dateTimeField.setValue(INITIAL_DATE_TIME);
+ dateTimeField.setDateFormat(FORMAT_PATTERN);
+ addComponent(dateTimeField);
+
+ zoneIdComboBox.addValueChangeListener(event -> {
+ String value = event.getValue();
+ if (value == null) {
+ dateTimeField.setZoneId(null);
+ } else {
+ dateTimeField.setZoneId(ZoneId.of(value));
+ }
+ });
+
+ localeIdComboBox.addValueChangeListener(
+ event -> dateTimeField.setLocale(event.getValue()));
+
+ patternTextField.addValueChangeListener(
+ event -> dateTimeField.setDateFormat(event.getValue()));
+ }
+
+}