Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Have a source field as 2018-10-10 as a date datatype. Would like to convert to 20181010, but it should be integer datatype. How can we achieve this by using tJavaRow?
Be aware that if your date is Stored as a Date, it will hold the complete date down to milliseconds. The code below shows converting from a String format (not required here, but I needed to do this to demonstrate how to do what you want) to a Date, and from a Date to an int.
//Set my date as a String String date = "2018-10-10"; //Create my Date - Not necessary for you Date myDate = routines.TalendDate.parseDate("yyyy-MM-dd", date); //Convert my Date to an int int myInt = Integer.parseInt(routines.TalendDate.formatDate("yyyyMMdd", myDate)); //Print out my int to prove it is correct System.out.println(myInt);
The above commands worked fine when using tJavaRow and running the job. But when I connect tJavaRow to tMSSqlOutput, I can't seem to sync the columns. It puts the original source column instead of the column defined after converting it to int in tJavaRow. What should I do to sync it?
You need to match the tMSSqlOutput schema with your tJavaRow output schema. Alternatively put a tMap between your tJavaRow and your tMSSqlOutput component. That will make it easier for you to connect your columns appropriately.