Date Picker not working while running in azure pipeline

79 views Asked by At

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)

Different Format Date

Not sure why this is happening only during the runs in the pipeline runs

We are expecting the date format which works fine locally

1

There are 1 answers

3
Bright Ran-MSFT On

I have a Java program sample like as below.

// TestCalendar.java

import java.util.*;
import java.text.*;
public class TestCalendar { 
    public static void main(String[] args) 
    { 
        // creating calendar object 
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat dateFormat = new SimpleDateFormat("ddMMyyyy");
      
        String currentDateTime = dateFormat.format(calendar.getTime());
        System.out.println("Current date: " + currentDateTime);
      
        calendar.add(Calendar.DATE, 2);
        String DateTime2dLater = dateFormat.format(calendar.getTime());
        System.out.println("2 days later: " + DateTime2dLater);
      
        calendar.add(Calendar.MONTH, 4);
        String DateTime4mLater = dateFormat.format(calendar.getTime());
        System.out.println("4 months later: " + DateTime4mLater);
      
        calendar.add(Calendar.YEAR, 2);
        String DateTime2yLater = dateFormat.format(calendar.getTime());
        System.out.println("2 years later: " + DateTime2yLater); 
    } 
}

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.

SimpleDateFormat dateFormat = new SimpleDateFormat("ddMMyyyy");

enter image description here