We have a functionality where we need to enter current date into the input field which i have given below
<input _ngcontent-hji-c324="" type="date" onfocus="(this.type='date')" id="plannedCompletionDate" placeholder="Planned completion date" class="ey-motif-form-control textbox-n ng-valid ng-touched ng-dirty">
This is the method which we are using through automation
SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyy");
Calendar c = Calendar.getInstance();
c.setTime(new Date()); // Use today date
c.add(Calendar.DATE, count); // Adding count value as days from the current date
System.out.println("Date to be added: " + count);
String output = sdf.format(c.getTime());
ReuseableFunctionalityBase.write_data_to_file(FileName, output, DataKey);
System.out.println(output);// Output is current date i.e 25-12-2023
This is working fine locally, But when we trigger this in azure pipeline we are getting the date inputed as different formart( Refer Screenshot)
Not sure why this is happening only during the runs in the pipeline runs
We are expecting the date format which works fine locally
I have a Java program sample like as below.
You can try to follow the above sample to update your Java code.
I have tried to compile and execute it on my local machine, in the pipeline runs on the self-hosted agents installed on the same local machine, and also in the pipeline runs on the Microsoft-hosted agents. All can work fine. All the output date are following the format (
ddMMyyyy
) set by the following code line.