Convert multiple input date formats to a single out format
davidl923 opened this issue · 2 comments
I get Date of Birth in two formats (YYYYMMDD and YYYYMMDDHHMMSS) and then need to output in a single format of MM-DD-YYYY.
I can convert one or the other to MM-DD-YYYY but don't know how to write an if then else statement in Java to convert whichever one is sent over.
I am no expert in Java scripting so any help would be appreciated. What I have used in the transformer is
DateUtil.convertDate("yyyy-MM-dd", "MM-dd-yyyy", msg['PID']['PID.7']['PID.7.1'].toString());
or
DateUtil.convertDate('yyyyMMdd','MM-dd-yyyy',DOBouput)
I think the question would be better left in the 'connect' discussion forum.
If you cut-off an existing time, it should work, e.g. like this:
var DOBoutput = msg['PID']['PID.7']['PID.7.1'].toString().substring(0,8);
var DOBResult = DateUtil.convertDate("yyyyMMdd", "MM-dd-yyyy", DOBoutput);
Is that the solution?
That is what I needed. Thank you for your quick response.