Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3165

Re: Java code for converting the data format.

$
0
0

Hi

 

Use below UDF:

UDF10.png

UDF11.png

 

public void dateTransEnhance(String[] date, String sourceFormat, String[] targetFormat, ResultList result, Container container) throws StreamTransformationException{
for (int i = 0; i < date.length; i++) {            SimpleDateFormat sourceDate = new SimpleDateFormat(sourceFormat[0]);            SimpleDateFormat targetDate = new SimpleDateFormat(targetFormat[0]);            try {                Date d = sourceDate.parse(date[i]);                result.addValue(targetDate.format(d));            } catch (ParseException e) {                e.printStackTrace();            }        }
}

Test:

test12.png

 

Regards,

Praveen.


Viewing all articles
Browse latest Browse all 3165

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>