22
33import com .microsoft .playwright .Locator ;
44import com .microsoft .playwright .Page ;
5+ import java .time .LocalDate ;
56import java .time .LocalTime ;
67import java .time .format .DateTimeFormatter ;
7-
8+ import java . util . Locale ;
89/**
910 * A helper class to work with vaadin-time-picker component.
1011 */
@@ -38,7 +39,7 @@ public TimePickerPw(Page page, String id) {
3839 */
3940 public void setValue (LocalTime value ) {
4041 String formattedTime = (timeFormat == null ? value .toString ()
41- : DateTimeFormatter .ofPattern (timeFormat ).format (value ));
42+ : DateTimeFormatter .ofPattern (timeFormat , Locale . ROOT ).format (value ));
4243
4344 root .fill (formattedTime );
4445 root .press ("Enter" );
@@ -48,6 +49,20 @@ public void setValue(LocalTime value) {
4849 options .setState (options .state .HIDDEN );
4950 page .waitForSelector ("vaadin-time-picker-overlay" , options );
5051 }
52+
53+ /**
54+ * Returns the value from the client side and parses it as
55+ * {@link LocalDate} using a {@link DateTimeFormatter}.
56+ *
57+ * @return the current value of the field
58+ */
59+ public LocalTime getValue () {
60+ String value = root .inputValue ();
61+ DateTimeFormatter formatter = DateTimeFormatter .ofPattern (timeFormat , Locale .ROOT );
62+
63+ return timeFormat == null ? LocalTime .parse (value )
64+ : LocalTime .parse (value , formatter );
65+ }
5166
5267 /**
5368 * Sets the format to be used when setting the time value.
0 commit comments