18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Not able to submit date in specific Format from excel sheet to script

hemohinihemohini Members
edited November -1 in Sahi - Open Source
I have problem with Excel sheet.

I want to submit date (dd-mm-yyyy hh:mm:ss) in this format from my excel sheet to Due Date field and check the validations with different combination, but currently sahi passes date as '2009-09-04 13:40:43' and because of this my script is getting failed.

Excel sheet DueDate column contains: '04-09-2009 13:40:43' and i have format this column with custom category.

Please provide the solution.

Comments

  • Hi,

    How are you submitting the date?

    Regards,
    Pankaj
  • hi,
    can anyone answer the question asked above..even am facing same problem
  • narayannarayan Administrators
    Hi Anu,

    You can use the code below to convert from one date format to another.
    function formatDate($origDate, $inFormat, $outFormat){
        var $inFormatter = new java.text.SimpleDateFormat($inFormat);
        var $outFormatter = new java.text.SimpleDateFormat($outFormat);
        return $outFormatter.format($inFormatter.parse($origDate));
    }
    
    var $origDate = "2009-09-04 13:40:43"
    var $inFormat = "yyyy-MM-dd HH:mm:ss"
    var $outFormat = "MM-dd-yyyy HH:mm:ss"
     
    var $formatted = formatDate($origDate, $inFormat, $outFormat);
    _assertEqual("09-04-2009 13:40:43", $formatted);
    

    Regards,
    Narayan
Sign In or Register to comment.