I am using SOAP UI Pro. I have a request from which this is an excerpt:
<ns2:OfficeType>
<ns2:OfficeTypeCode>M</ns2:OfficeTypeCode>
<ns2:EffectiveDate>2000-01-01</ns2:EffectiveDate>
<ns2:TerminationDate>9999-12-31</ns2:TerminationDate>
<ns2:IsPrimary>true</ns2:IsPrimary>
</ns2:OfficeType>
Instead of for instance, 2000-01-01, I want to use today (so for the day I am writing this it would be 2015-03-10. You may be reading on March 12 in which case it would be 2015-03-12, etc.). I could theoretically edit the SOAP request each time I send it out and replace the fields with the current date, but this is supposed to be automatic. I would like a say to say, instead of 2010-01-01 use something like $(Today'YYYY-MM-DD') (that is just an example probably nothing near the actual syntax).
Is there a way to get the current date placed into a SOAP UI message from SOAP UI Pro?
In SOAPUI you can use groovy code directly in your SOAP Request using the follow notation ${=groovy expression}, so in your case you can use ${=new java.text.SimpleDateFormat("yyyy-MM-dd").format(new java.util.Date())} to get today date in yyyy-MM-dd format.
Directly in your test request you can use:
<ns2:OfficeType>
<ns2:OfficeTypeCode>M</ns2:OfficeTypeCode>
<ns2:EffectiveDate>${=new java.text.SimpleDateFormat("yyyy-MM-dd").format(new java.util.Date())}</ns2:EffectiveDate>
<ns2:TerminationDate>9999-12-31</ns2:TerminationDate>
<ns2:IsPrimary>true</ns2:IsPrimary>
</ns2:OfficeType>
Hope this helps,
This will give you a nice UTC formated date/time:
<ns2:EffectiveDate>${=java.time.Instant.now().truncatedTo(java.time.temporal.ChronoUnit.SECONDS)}</ns2:EffectiveDate>
If you are using SoapUI Pro, then you may have the following script in TestRunListener.beforeRun Event
import java.text.SimpleDateFormat
def today = new Date()
def dateFormat = new SimpleDateFormat("yyyy-MM-dd")
def date = dateFormat.format(today)
log.info date
testRunner.testCase.setPropertyValue('DATE', date)
And in the request have
<ns2:EffectiveDate>${#TestCase#DATE}</ns2:EffectiveDate>
i.e., using the value DATE which was set in the beforeRun event.
Note: You can change the date format whatever you want, here it is used yyyy-MM-dd format as you mentioned in the question.
Related
in Java I set the date as time in mSec since 1970, e.g. futuredate=1640995200000l //1 Jan 2022.
When this is compiled into JavaScript by GWT, I believe it uses the Jsdate library which says it is a native javascript date object
1 jan 2022 ends up as this object in the JavaScript _.futuredate={l:3120128, m:391243, h:0}
Can someone help me interpret this format please, it doesn't quite make sense to me
thanks
To work with date and time on the GWT client side one can use com.google.gwt.i18n.shared.DateTimeFormat. com.google.gwt.i18n.shared.DateTimeFormat.PredefinedFormat includes already many predefined formats, but you can naturally use your own, such as "EEEE, y MMMM dd".
Based on your example:
Date myDate = DateTimeFormat.getFormat("dd.MM.yyyy").parse("01.01.2022");
DateTimeFormat myFormat = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601);
String s = myFormat.format(myDate);
The first line only simulates the date that you already set in Java and it is meant to show another example of a date format and how to parse a String.
I'm migrating a whole bunch of web pages that were written in classic asp over to a new server, and have discovered many references to the simple date() function, like:
if cint(left(date,instr(date,"/")-1)) < 9 then blah blah
I'm getting errors because the new server's default date format is returning yyyy-mm-dd, and the code above is expecting it to be in dd/mm/yyyy format.
Rather than manually fixing every occurrence, of which there could be hundreds, I'm looking to see if I can change the default date format for asp so that date() returns dd/mm/yyyy. I thought by simply changing the system's short date format would do the trick, but even after restarting the server it's still showing yyyy-mm-dd.
Is there a setting somewhere where you can specify the default date format when using the date() function?
This worked for me:
change global.asa, in the Sub Session_OnStart, add a line
Session.LCID=1033
I'm currently working with embarcadero c++, this is the first time I'm working with it so it's completely new to me.
What I'm trying to achieve is to get the current date, make sure the date has the "dd/MM/yyyy" format. When I'm sure this is the case I want to add a month to the current date.
So let's say the current date is 08/18/2016 this has to be changed to 18/08/2016 and then the end result should be 18/09/2016.
I've found that there is a method for this in embarcardero however I'm not sure how to use this.
currently I've only been able to get the current date like this.
TDateTime currentDate = Date();
I hope someone will be able to help me out here.
I figured it out.
After I've searched some more I found the way to use the IncMonth method on this page.
The example given my problem is as follows:
void __fastcall TForm1::edtMonthsExit(TObject *Sender)
{
TDateTime StartDate = edtStartDate->Text;
int Months = edtMonths->Text.ToInt();
TDateTime NextPeriod = IncMonth(StartDate, Months);
edtNextPeriod->Text = NextPeriod;
}
After looking at I changed my code accordingly to this
TDateTime CurrentDate = Date();
TDateTime EndDate = IncMonth(CurrentDate, 1);
A date object doesn't have a format like "dd/MM/yyyy". A date object is internally simply represented as a number (or possibly some other form of representation that really isn't your problem or responsibility).
So you don't have to check if it's in this format because no date objects will ever be in this format, they simply don't have a format.
You will have to do additions/subtractions on the Date object that the language or library gives you, THEN (optionally) you can format it to a human-readable string so it looks like 18/08/2016 or 18th of August 2016 or whatever other readable format that you choose.
It might be that the TRANSFER of a date between 2 systems is in a similar format, but then formatting the date like that is entirely up to you.
As for how to do that, the link you posted seems like a possible way (or alternatively http://docwiki.embarcadero.com/Libraries/Berlin/en/System.SysUtils.IncMonth), I'm afraid I can't give you an example as I'm not familiar with the tool/language involved, I'm just speaking generically about Date manipulations and they should ALWAYS be on the raw object.
I am trying to compare and check the date if it is today's date or not in a spesific program. I tried to use assertion method but when I use it the time will remain same if you try it next day. The main problem that I need to know when open a page from program It should be today's date and should be passed. if you know already anything about it please let me know also :)
Thanks yo!
Use System.DateTime.Now.ToString("yyyy-MM-dd") as one argument of the assertion. You may need to use a different format rather in the ...ToString() method. The exact format depends on how the date is shown on the screen.
This could be done using "StringAssert" to verify that your programs date string contains today's date string, while ignoring the time:
var programDateString = "7/25/2016 12:00:00"; //this is an example of your date retrieved from the application with time included
var todaysDate = System.DateTime.Today.ToShortDateString(); //short date string
StringAssert.Contains(programDateString, todaysDate);
I am in the unfortunate position that I need to use a composite id in a Grails app where I work with legacy data. This means I have to override some actions in the controller, but as I did this I was struck by the fact that I could not use use a date argument directly as a parameter to a dynamic method.
Instead of just doing MyLegacyObj.findBySystemIdAndLogDate(params.systemId, params.logDate), I first needed to parse the date string before giving it to the dynamic method. To further complicate matters I had no idea what format the date string had (until I added lots of log.debug() string to the output). So now I have a bit of code looking like this
def formatter = new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy")
MyLegacyObj.findBySystemIdAndLogDate(params.systemId, formatter.parse(params.logDate));
This feels unoptimal, no to say dangerous (what if the date format changes with the locale?)? What would be a recommended way of doing this, and do I really need to parse dates at all?
Date is a pretty complex object and params are just Strings, so Date is submitted in parts. It is "magically" assembled from the parts when assigning x.properties = params.
Command object will do the work for you, if you add a Date field to it.
It has nothing to do with methods' dynamic or static invocation. Your GSP that renders Date editor might interfere too.