Hi,
Also, I believe the getarguments is incorrect, it is a method call, from
the top of my heard it should be:
incomingrequest.getArguments().get("firstDate")
Cheers,
Danny
--
This electronic communication and the information and any files transmitted
with it, or attached to it, are confidential and are intended solely for
the use of the individual or entity to whom it is addressed and may contain
information that is confidential, legally privileged, protected by privacy
laws, or otherwise restricted from disclosure to anyone else. If you are
not the intended recipient or the person responsible for delivering the
e-mail to the intended recipient, you are hereby notified that any use,
copying, distributing, dissemination, forwarding, printing, or copying of
this e-mail is strictly prohibited. If you received this e-mail in error,
please return the e-mail to the sender, delete it from your computer, and
destroy any printed copy of it.
Original Message:
Sent: 8/12/2022 11:59:00 AM
From: Karl Miller
Subject: RE: how to compare two dates ( received in xml request ) in match script ?
You need to import a couple of classes:
import java.text.*;
import java.util.Calendar;
also you did not pass a correct string passed to SimpleDateFormat method:
and replace
DateFormat formatter=new SimpleDateFormat(yyyy-mm-dd);
with
DateFormat formatter=new SimpleDateFormat("yyyy-mm-dd");
also consider adding a clause to handle if the dates are blank or some other issue and then
return defaultMatcher.matches();
------------------------------
Karl M.
DevOps Capability Specialist
Broadcom
------------------------------
Original Message:
Sent: Aug 10, 2022 10:30 AM
From: Poonam Walke
Subject: how to compare two dates ( received in xml request ) in match script ?
Hi,
I trying to compare two dates which received in request(xml) in match script.
But after running the test case, its showing exception on devtest portal as 'there is an exception occured in match script'
Could anyone please tell what is wrong in below script?
My match script :
String firstDate = incomingrequest.getarguments.get(firstDate);
String secondDate = incomingrequest.getarguments.get(secondDate);
DateFormat formatter=new SimpleDateFormat(yyyy-mm-dd);
Date first= formatter.parse(firstDate);
Date second= formatter.parse(secondDate);
if(first.after(second)){
return true;
}else {
return false;
}