Service Virtualization

Expand all | Collapse all

Problem with the date format

  • 1.  Problem with the date format

    Posted Oct 30, 2018 04:31 PM

    Hi.

     

    I have a problem with the format of the date. I am virtualizing a service and, in one of the labels, I must return a value to the current date.

     

    How can I return the value with sysdate?

     



  • 2.  Re: Problem with the date format

    Broadcom Employee
    Posted Oct 30, 2018 04:43 PM

    You have a date format with no timezone information. I don't think the specific format you've got, which is yyyy-MM-dd'T'HH:mm:ss is listed in lisa.properties

     

    My suggestion is to search this community for posts about "date format" and you'll see lots of information about adding your format to the list of formats that will be automatically replaced in DevTest with "doDateDeltaFrom..." lines, which will do what you want.



  • 3.  Re: Problem with the date format

    Broadcom Employee
    Posted Oct 30, 2018 04:57 PM

    Rick’s suggestion will give you a permanent solution so that DevTest will recognize these strings during a recording and replace them automatically with a doDateDelta expression.

     

    If you just want to quickly fix this response then replace the string with below:

     

    {{=doDateDeltaFromCurrent("yyyy-MM-dd'T'HH:mm:ss");/2018-10-30T00:00:00/}}

     

     

    Cheers,

    Danny



  • 4.  Re: Problem with the date format

    Posted Oct 30, 2018 05:07 PM

    Thanks Rick / Danny

     

    Take the test with Danny's suggestion.

     

    At the time of validation in SoapUI, the answer is {{= doDateDeltaFromCurrent ("yyyy-MM-dd'T'HH: mm: ss"); / 2018-10-30T00: 00: 00 /}}

     

     



  • 5.  Re: Problem with the date format

    Broadcom Employee
    Posted Oct 30, 2018 05:14 PM

    Apologies, something might have gone wrong when I copy-pasted in Outlook. The expression is missing the "*"s 

    Try:

    {{=doDateDeltaFromCurrent("yyyy-MM-dd'T'HH:mm:ss");/*2018-10-30T00:00:00*/}}



  • 6.  Re: Problem with the date format

    Broadcom Employee
    Posted Oct 30, 2018 05:19 PM

    Does it work without adding the offset as an argument? The things you learn!



  • 7.  Re: Problem with the date format

    Broadcom Employee
    Posted Oct 30, 2018 05:25 PM

    No, it probably won’t, I was doing this from the top of my head and it felt a bit odd writing it down but I couldn’t put my finger on it.

     

    @jemartineza, ignore what I sent before, use this: {{=doDateDeltaFromCurrent("yyyy-MM-dd'T'HH:mm:ss", "0D");/2018-10-30T00:00:00/}}

     

     

    Cheers,

    Danny



  • 8.  Re: Problem with the date format

    Posted Oct 30, 2018 08:12 PM

    Hi Danny.

     

    Make the modifications you told me and keep showing the whole chain

     

     



  • 9.  Re: Problem with the date format

    Broadcom Employee
    Posted Oct 30, 2018 05:26 PM

    @Rick, thanks for spotting this.

     

    Cheers,

    Danny



  • 10.  Re: Problem with the date format

    Broadcom Employee
    Posted Oct 31, 2018 02:14 AM

    The magic string expression again got "corrupted" after I sent it. As you can see from other magic strings in your response, the last part is the default value which is used if a property doesn't exist, it has to start with /* and end with */.

     

    So, the correct expression is {{=doDateDeltaFromCurrent("yyyy-MM-dd'T'HH:mm:ss", "0D");/*2018-10-30T00:00:00*/}}

    (fingers crossed that it should work this time :-) )

     

    I am starting to understand what happens, when my mail contains /*<someText>*/ it is converted by this site into /<someTextInBold>/ , so that's an attention point for any email posts in the future.

     

    Cheers,

    Danny



  • 11.  Re: Problem with the date format

    Posted Oct 31, 2018 11:36 AM

    Hi Danny

    I'm still having the same problem.

    The idea is that this tag sends me the current date always.

     

     

     

     



  • 12.  Re: Problem with the date format



  • 13.  Re: Problem with the date format

    Broadcom Employee
    Posted Oct 31, 2018 01:03 PM

    Ok if you have a solution (that was always the goal   )

     

    Cheers,

    Danny



  • 14.  Re: Problem with the date format
    Best Answer

    Broadcom Employee
    Posted Oct 31, 2018 01:05 PM

    Yes, this function calculates the current date/timestamp and that value replaces the {{…}}

     

    There is just something wrong with the syntax, I see a space between the equal sign (=) and the doDateDelta… Try it with that removed.

     

    Cheers,

    Danny



  • 15.  Re: Problem with the date format

    Posted Oct 31, 2018 01:09 PM

    Hi Danny

     

    It worked

     

    Thank you