Below you will find the JavaScript / ECMAScript code which will convert JD Edwards Julian Dates to Java dates. The output format can be tweaked to your liking.
// According to the Oracle doc for JDE it’s C + YY + DDD
// C = Century 0 = 19, 1 = 20
// 097065 1997 and the 65th day of the year.
// 071138 138th day of 1971 = MM 05 / DD 19 / 1971
importClass(java.text.SimpleDateFormat);
var varMyDate = "71069";
print ("JDE Date: " + varMyDate);
var varParsedDate = parseString(varMyDate);
print ("Out Date: " + varParsedDate);
function parseString(varString)
{
if (varString.length == 5)
{
varString = 0 + varString;
}
if (varString.length != 6) return;
var varCentury = varString.substring(0,1);
var varYear = varString.substring(1,3);
var varDay = varString.substring(3,6);
varYear = +varCentury + +19 + varYear;
// print (varCentury);
// print (varYear);
// print (varDay);
return dateFromDay(varYear, varDay);
}
function dateFromDay(year, day)
{
pattern = "yyyyMMdd";
format = new SimpleDateFormat(pattern);
var varDate = new Date(year, 0);
var varTempDate = new Date(varDate.setDate(day));
return format.format(varDate);
}
The code handles leap year conversion, as the following examples show.
2004 is a LEAP year, 1971 is not.
Kekes-MacBook-Pro:Downloads karmst$ rhino -f jimbo.js
JDE Date: 104138
Out Date: 20040517
Kekes-MacBook-Pro:Downloads karmst$ rhino -f jimbo.js
JDE Date: 071069
Out Date: 19710310