[OIC] How to convert date in dd/mm/yyyy format to dd-mm-yyyy format in OIC?

 

In this post we will see how to convert yyyy/mm/dd date format to dd-mon-yyyy format. This method can be applied to convert date in one format to any other format.

 

Suppose we have the date as 2024/12/17, which is 17-Dec-2024. This can be represented as below in index format:

 

 

 

So, to convert the date  2024/12/17 to 17-12-2024 we will use the sub string function. 

 

substring(date,9,2) will pick 2 character from index 9 which is 17

substring(date,6,2) will pick 2 character from index 6 which is 12

substring(date,1,4) will pick 4 character from index 1 which is 2024

 

So, together we can use the below expression:

concat (
substring (ns24:Transaction_Date, 9, 2 ), "-"
, substring (ns24:Transaction_Date, 6, 2 ), "-"
, substring (ns24:Transaction_Date, 1, 4 ) 
)
 
Expression in Mapper will look like:  
 
 
 
 
Also, in mapper you can use the below test condition to check for null values:
 
<nstrgmpr:transactionDate xml:id="id_120">
<xsl:choose>
<xsl:when test="string(ns24:Transaction_Date) != ''">
<xsl:value-of xml:id="id_121" select="concat (
substring (ns24:Transaction_Date, 9, 2 ), &quot;-&quot;
, substring (ns24:Transaction_Date, 6, 2 ), &quot;-&quot;
, substring (ns24:Transaction_Date, 1, 4 ) )"/>
      </xsl:when>
 </xsl:choose>
</nstrgmpr:transactionDate>
 
 

Comments