Forum Discussion

ramzsvs's avatar
ramzsvs
Occasional Visitor
4 years ago
Solved

How to covert milliseconds to UTF date format to verify from DB

When I send request I am getting response in milliseconds [1576522684000], how can I covert it to UTF date format 2019-12-16-13:58:06.070000 to validate my request and DB response. Thanks in advance.

  • richie's avatar
    richie
    4 years ago

    Hey ramzsvs

    Sorry, i only just noticed this ticket, f youre still struggling, try this

    def milval=testCase.getPropertyValue("valuepropname").toLong
    
    log.info new Date(milval).format("yyyy-MM-dd'T'Hh:mm:ss.SSS'Z'")



    Ta

    Rich

3 Replies

  • rajs2020's avatar
    rajs2020
    Frequent Contributor

    You can search google for how to do this. If you want to do the conversion with a Groovy script, then here are the keywords I would use - "java convert milliseconds to utc date". You can try using groovy instead of java also, but java will give more results. We can use java libraries inside our groovy scripts.

    Similarly, if you wanted to do the conversion with sql instead, you can search for "sql convert milliseconds to utc date". You can also mention the dialect of sql you are using such as sql server, mysql etc.

    Here are all the java based google search results from stackoverflow:
    https://www.google.com/search?q=java+convert+milliseconds+to+utc+date+site:stackoverflow.com

    good luck!

    • TanyaYatskovska's avatar
      TanyaYatskovska
      SmartBear Alumni (Retired)

      Thanks for your help, rajs2020!

       

      ramzsvs, did this suggestion help? Please let us know if you are still looking for the solution.

      • richie's avatar
        richie
        Community Hero

        Hey ramzsvs

        Sorry, i only just noticed this ticket, f youre still struggling, try this

        def milval=testCase.getPropertyValue("valuepropname").toLong
        
        log.info new Date(milval).format("yyyy-MM-dd'T'Hh:mm:ss.SSS'Z'")



        Ta

        Rich