One Star

How to convert calendar date to julian using tmap.

Hi,
Could you help with converting calendar date to Juilan using tmap processing.
I am reading data using tmssqlinput and going to insert data in JDE using AS400.
I attached a screenshot of source data and data, audo date need to be converted in to julian date.
Help would be appreciated.!
Thanks
Pranav
4 REPLIES
One Star

Re: How to convert calendar date to julian using tmap.

I think that you can add some routine to have a function like DatetoJulian that you could use in tMap.
But you can do it using Java component :
http://stackoverflow.com/questions/14535983/convert-a-regular-date-to-julian-date-and-vice-versa-in-...
One Star

Re: How to convert calendar date to julian using tmap.

Will it going to work on the date format i have?
DD/MM/YY
One Star

Re: How to convert calendar date to julian using tmap.

If I look at the code of the link, 
I can see : 
dayS = unformattedDate.substring(0,2);
monthS = unformattedDate.substring(3, 5);
yearS = unformattedDate.substring(6, 10);
So actually, the format date is DD/MM/YYYY
You can try with your format, but I think it'll need to be DD/MM/YYYY format.
You should convert it.
One Star

Re: How to convert calendar date to julian using tmap.

Hi, 
I found one code in our Routine and when i used in a job, i got following error.
Exception in component tMSSqlInput_1
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(Unknown Source)
Code
public static String getJDEJulianDate(String CalendarDate_MMddyyyy)
   {
String strYYY = "";
int intdays = 0;
String strJulianDate = "";

try {

SimpleDateFormat sdf = new SimpleDateFormat("MMddyyyy");
Calendar calDate = Calendar.getInstance();
calDate.setTime(sdf.parse(CalendarDate_MMddyyyy));
if (calDate.get(Calendar.YEAR) > 1999)
{
strYYY = "1" + Integer.toString(calDate.get(Calendar.YEAR)).substring(2);
}
else
{
strYYY = Integer.toString(calDate.get(Calendar.YEAR)).substring(2);
}
intdays = calDate.get(Calendar.DAY_OF_YEAR);
if (intdays < 100)
{
strJulianDate = strYYY + "0" + Integer.toString(intdays);
}
else
{
strJulianDate = strYYY + Integer.toString(intdays);
}
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return strJulianDate;
}
Thanks
Pranav