Forum Discussion

testhrishi's avatar
testhrishi
Frequent Contributor
7 years ago

During Property transfater is it possible to convert Dateformat from 2017-11-03T18:42:00Z to Date?

I would like to convert date from format 2017-11-03T18:42:00Z to time and altimately may be able to calculate difference betwen 2 time stamps. Is there a function I can use at property transfer? to conver string to Date may be

ALso is there a groovy script to do the calculations?

6 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    What do you mean by "convert Dateformat from 2017-11-03T18:42:00Z to sec?"

    Hope you know why property transfer is used and you may aware that it is not for applying a custom logic.

    You could replace Property Transfer step with "Script Assertion" / Groovy Script test step to achieve the same.

    But you need to clarify what exactly is required.
    • testhrishi's avatar
      testhrishi
      Frequent Contributor

      I was thinking some kind of xpath function that can be use here

      • nmrao's avatar
        nmrao
        Champion Level 3
        Would you please clarify the question posed in the last reply?
  • testhrishi's avatar
    testhrishi
    Frequent Contributor

    I was able to get around this using groovy and getTime() function

      • testhrishi's avatar
        testhrishi
        Frequent Contributor

        This worked for what I was trying to do.

         

         

        def format1 = context.expand( '${#TestCase#parseEnd}' )
        def format2 = context.expand( '${#TestCase#IncorporationStart}' )
        def format3 = Date.parse("yyyy-MM-dd'T'hh:mm:ss'Z'", format1)
        def format4 = Date.parse("yyyy-MM-dd'T'hh:mm:ss'Z'", format2)


        long timeDiff = (format4.getTime() - format3.getTime())/1000