Okay, my own Maven POM was "too correct" in order to reproduce your
error. You ought to change a few things:

  -- Geb 3.3 depends on Groovy 2.5.6, so you want to use at least
       ** org.codehaus.groovy:groovy:2.5.6
       ** org.spockframework:spock-core:1.2-groovy-2.5

  -- Class DateGroovyMethods (adding dynamic methods to Date) is
     deprecated in Groovy 2.5, you want to use class DateUtilExtensions
     instead. But for that you ought to add dependency
       ** org.codehaus.groovy:groovy-dateutil:2.5.6

Then a test like this works:

package de.scrum_master.geb

import geb.spock.GebSpec
import groovy.time.TimeCategory

class CalendarTest extends GebSpec {
  def test() {
    given:
    println Calendar.getInstance().format('MMddHHmmss')
    use(TimeCategory) {
      println 8.weeks.ago.format('MMddHHmmss').toString()
    }

    expect:
    true
  }
}

It prints something like:

0405172557
0209000000


-- 
Alexander Kriegisch
https://scrum-master.de


Alexander Kriegisch schrieb am 05.04.2020 16:51 (GMT +07:00):

> I am not a Geb guy, I use Maven. But I created a little sample project,
> trying to use the same dependency versions as you, and did not notice
> any anomalies with calendar instances or time units. If you do have
> problems, please be so kind as to make them reproducible by publishing
> an MCVE [1] on GitHub. I like to have a full Gradle or Maven project and
> a Spock or Geb test reproducing your problem. By the way, you did not
> even explain what the problem is, except saying "doesn't work". I see no
> detailed error description, no stacktrace or anything else that could be
> helpful.
> 
> [1] https://stackoverflow.com/help/mcve
> 
> Looking forward to your update :-)
> 
> -- 
> Alexander Kriegisch
> https://scrum-master.de
> 
> 
> Gordon Freeman schrieb am 03.04.2020 20:59 (GMT +07:00):
>> 
>> Hi, everyone! 
>> I would like to discuss one strange behavior with Calendar in 3.4 version
>> of GEB.
>> Previously we used old version 2.1 and such construction worked perfectly:
>> 
>> 
>> Calendar.getInstance().format('MMddHHmmss')
>> 
>> 
>> But I decided to try the newest version 3.4:
>> 
>> 
>> Calendar.getInstance().format('MMddHHmmss')// - doesn`t work format()
>> 
>> 
>> I was able to 'fix' it just changed to:
>> 
>> 
>> Calendar.getInstance().toOffsetDateTime().format("MMddHHmmss")
>> 
>> 
>> But we used such constructions in more than 100 places, fine I can do
>> refactor, but also noticed that 'TimeCategory' is not working in new GEB
>> version, next construction was working in GEB 2.1 but in 3.4 doesn`t work:
>> 
>> 
>> newDate=null
>> use(TimeCategory) {
>> newDate = 8.weeks.ago.format('MMddHHmmss').toString()
>> println(newDate)
>> }
>> 
>> 
>> How can I fix this? Is it possible do not refactor everything with new
>> version of GEB?
>> 
>> Thanks in advance!
>> 
>> 
>> Just in case, our dependencies:
>> 
>> 
>> reportiumVersion = '2.3.1'
>> gebVersion = '2.1' //3.4 also tried
>> groovyVersion = '2.4.12'
>> junitVersion = '5.6.1'
>> seleniumVersion = '3.141.59'
>> 
>> 
>> dependencies {
>> 
>> compile "org.gebish:geb-spock:$gebVersion"
>> 
>> compile "org.codehaus.groovy:groovy-all:$groovyVersion"
>> 
>> compile "com.perfecto.reporting-sdk:reportium-java:$reportiumVersion"
>> 
>> compile "com.perfecto.reporting-sdk:reportium-testng:$reportiumVersion"
>> 
>> compile group: 'org.ccil.cowan.tagsoup', name: 'tagsoup', version: '1.2.1'
>> 
>> testCompile("org.spockframework:spock-core:1.2-groovy-2.4") {
>> 
>> exclude group: "org.codehaus.groovy"
>> 
>> }
>> 
>> testCompile('com.athaydes:spock-reports:1.3.1') {
>> 
>> transitive = false 
>> 
>> }
>> 
>> testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion")
>> 
>> compile "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
>> 
>> compile "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
>> 
>> compile "org.seleniumhq.selenium:selenium-ie-driver:$seleniumVersion"
>> 
>> compile "org.seleniumhq.selenium:selenium-remote-driver:$seleniumVersion"
>> 
>> compile "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
>> 
>> }
>> 
>> 
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Geb User Mailing List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected]
>> <mailto:[email protected]> .
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/geb-user/386a81cd-1c87-4653-b903-89cf81bf9192%40googlegroups.com
>> <https://groups.google.com/d/msgid/geb-user/386a81cd-1c87-4653-b903-89cf81bf9192%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
> 
> -- 
> You received this message because you are subscribed to the Google Groups "Geb
> User Mailing List" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email
> to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/geb-user/20200405095159.C7A5544C03D8%40dd39516.kasserver.com.
> 

-- 
You received this message because you are subscribed to the Google Groups "Geb 
User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/geb-user/20200405102643.A8C7444C041A%40dd39516.kasserver.com.

Reply via email to