Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All
I have used below code to convert from string to date , but still I'm getting the below errors
I have used below expression
routines.utils.stringToDate(row2.StartDate, "dd-MM-yyyy")
and I'm getting below error
java.text.ParseException: Unparseable date: "1/1/2019"
at java.text.DateFormat.parse(Unknown Source)
at routines.utils.stringToDate(utils.java:707)
at sf_atos.testing_0_1.testing.tFixedFlowInput_2Process(testing.java:896)
at sf_atos.testing_0_1.testing.runJobInTOS(testing.java:2104)
at sf_atos.testing_0_1.testing.main(testing.java:1948)
java.text.ParseException: Unparseable date: "25/01/2019"
at java.text.DateFormat.parse(Unknown Source)
at routines.utils.stringToDate(utils.java:707)
at sf_atos.testing_0_1.testing.tFixedFlowInput_2Process(testing.java:896)
at sf_atos.testing_0_1.testing.runJobInTOS(testing.java:2104)
at sf_atos.testing_0_1.testing.main(testing.java:1948)
.---------.
|tLogRow_2|
|=-------=|
|StartDate|
|=-------=|
|null |
|null |
'---------'
The output is coming null
Hello amitdadri,
if your inputs 1/1/2019, 25/01/2019, 23/1/2019 are of type Date, then you can convert them to "yyyy-MM-dd" Strings with TalendDate.formatDate("yyyy-MM-dd", row1.yourInputDate). If your inputs are Strings, convert them to Date format with TalendDate.parseDate("dd/MM/yyyy", row5.yourInputString) first, then apply the formatDate function mentioned before.
Best regards,
Thomas
Is it possible to put the screen capture of your tmap? it will be useful to see the datatype you used in the source and target
try the following functions:
TalendDate.format("yyyy-MM-dd", row.myDate)
TalendDate.parseDate("dd.MM.yyyy",row1.Clearing_Date)
TalendDate.formatDate("yyyyMMdd",row6.Date)
(Var.date==null || Var.date.isEmpty())? null : TalendDate.parseDate("MM/dd/yyyy",TalendDate.formatDate("MM/dd/yyyy",TalendDate.parseDate("MM/dd/yyyy",Var.date)))
Thanks for the reply @Manoj_MUTHURAJA
what you have suggested is giving bit different output for two different values i provided
Input values 1/1/2019 and 25/01/2019
corresponding output that i got
|StartDate |
|=--------=|
|2019-01-01|
|2021-01-01|
'----------'
For first value it's working fine , but for second value its giving wrong output.
Would be a great help if you suggest solution to this
it's normal the data is of different type because the the function you gave is yyyy-mm-dd
now you can change the format to dd-mm-yyyyy ,try and see and tell me what it gives
I don't know how to help more.Either You can put the screen capture of the full tmap or otherwise use the tmap:
use this link for reference
https://www.youtube.com/watch?v=2TCmUs8_9uM
please look at the screen capture I have attached below.
I am sure it could be useful for you.
Hello amitdadri,
if your inputs 1/1/2019, 25/01/2019, 23/1/2019 are of type Date, then you can convert them to "yyyy-MM-dd" Strings with TalendDate.formatDate("yyyy-MM-dd", row1.yourInputDate). If your inputs are Strings, convert them to Date format with TalendDate.parseDate("dd/MM/yyyy", row5.yourInputString) first, then apply the formatDate function mentioned before.
Best regards,
Thomas