AnsweredAssumed Answered

How to convert to Date format in Gel script

Question asked by JayaSantoshKumar on Jan 7, 2016
Latest reply on Jan 7, 2016 by JayaSantoshKumar

Hello Everyone, I'm reading a file which has dates is dd/mm/yyyy Format now I'm trying it to convert them to  yyyy-mm-dd Format
I'm new to Gel and couldn't track my code where it is going wrong .

I'm able to read from file and Write to File , but unable to convert to yyyy-mm-dd Format
Could you please help me out

 

Here is my Code

<gel:script

xmlns:core="jelly:core"

xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"

xmlns:file="jelly:com.niku.union.gel.FileTagLibrary"

>

 

<core:new className="java.util.Date" var="date"/>

 

<!-- Reading File from Provided Path -->

<gel:parameter default="D:\Gel Script Docs\JS Custom Scripts\Dates Task\dates.txt" var="infile"/>

<file:readFile fileName="${infile}" var="infileParsed" embedded="false"/>           

 

 

<!-- Writing to File in yyyy-mm--dd Format -->

        <file:writeFile

        delimiter=","

        embedded="false"

        fileName="D:\Gel Script Docs\JS Custom Scripts\ReadWriteResult.txt">

 

          <core:forEach items="${infileParsed.rows}" var="row" indexVar="i" begin="0" step="1">

          

            <file:line>

            <gel:formatDate format="yyyy-MM-dd" stringVar="mydate" dateVar="row[0]"/>

                                <file:column value="${mydate[0]}" />

                            </file:line>

          

          </core:forEach>

        </file:writeFile>

<!-- Writing to File is closed here -->

 

<!-- FORMAT DATE -->

<gel:formatDate format="yyyy-MM-dd" stringVar="today" dateVar="date"/>

<gel:out> <gel:formatDate format="yyyy-MM-dd"  dateVar="date"/></gel:out>

<gel:out>

today Date== ${today}

</gel:out>

 

 

</gel:script>

 

Error in Command Prompt is : Non-Date variable used as Date.

Outcomes