@@ -96,10 +96,9 @@ class DefaultDateHelperSpec extends Specification {
9696 null | ' 8:00 AM'
9797 }
9898
99- @PendingFeature
100- @Requires ({ !Jvm .current.isJava17() })
99+ @Requires ({ Jvm .current.isJava20Compatible() })
101100 @Unroll
102- void " Java 21 + - Full getTimeFormat for style #style returns #expected" (String style, String expected) {
101+ void " Java 20 + - getTimeFormat for style #style returns #expected" (String style, String expected) {
103102 given :
104103 DateTimeFormatter format
105104
@@ -111,8 +110,10 @@ class DefaultDateHelperSpec extends Specification {
111110 format. format(localTime) == expected
112111
113112 where :
114- style | expected
115- ' FULL' | ' 8:00:00 AM UTC'
113+ style | expected
114+ ' LONG' | ' 8:00:00 AM UTC'
115+ ' MEDIUM' | ' 8:00:00 AM'
116+ null | ' 8:00 AM'
116117 }
117118
118119 @Requires ({ Jvm .current.isJava17() })
@@ -133,6 +134,24 @@ class DefaultDateHelperSpec extends Specification {
133134 ' FULL' | ' 8:00:00 AM Coordinated Universal Time'
134135 }
135136
137+ @Requires ({ Jvm .current.isJava20Compatible() })
138+ @Unroll
139+ void " Java 20+ - Full getTimeFormat for style #style returns #expected" (String style, String expected) {
140+ given :
141+ DateTimeFormatter format
142+
143+ when :
144+ format = helper. getTimeFormat(style, ZoneId . of(' UTC' ), Locale . ENGLISH )
145+
146+ then :
147+ format. zone == ZoneId . of(' UTC' )
148+ format. format(localTime) == expected
149+
150+ where :
151+ style | expected
152+ ' FULL' | ' 8:00:00 AM Coordinated Universal Time'
153+ }
154+
136155 @Requires ({ jvm.isJava8() })
137156 @Unroll (" for getDateTimeFormat(#dateStyle, #timeStyle) => #expected" )
138157 void " Java 8 - test getDateTimeFormat" (String dateStyle, String timeStyle, String expected) {
@@ -175,6 +194,27 @@ class DefaultDateHelperSpec extends Specification {
175194 null | null | ' 1/5/41, 8:00 AM'
176195 }
177196
197+ @Requires ({ Jvm .current.isJava20Compatible() })
198+ @Unroll (" for getDateTimeFormat(#dateStyle, #timeStyle) => #expected" )
199+ void " Java 20+ - test getDateTimeFormat" (String dateStyle, String timeStyle, String expected) {
200+ given :
201+ DateTimeFormatter format
202+
203+ when :
204+ format = helper. getDateTimeFormat(dateStyle, timeStyle, ZoneId . of(' UTC' ), Locale . ENGLISH )
205+
206+ then :
207+ format. zone == ZoneId . of(' UTC' )
208+ format. format(LocalDateTime . of(localDate, localTime)) == expected
209+
210+ where :
211+ dateStyle | timeStyle | expected
212+ ' FULL' | ' FULL' | ' Sunday, January 5, 1941, 8:00:00 AM Coordinated Universal Time'
213+ ' LONG' | ' LONG' | ' January 5, 1941, 8:00:00 AM UTC'
214+ ' MEDIUM' | ' MEDIUM' | ' Jan 5, 1941, 8:00:00 AM'
215+ null | null | ' 1/5/41, 8:00 AM'
216+ }
217+
178218 void " test supportsDatePickers" () {
179219 expect :
180220 helper. supportsDatePicker(Date )
0 commit comments