Friday, October 31, 2014

Get the Date and Time inside MEC Mapper

While doing some MEC developments my team encountered a requirement where we have to send the result to an outbound as a flat file, and the name of the file should be

<specificationCode>.yyyyddmmhhmmss.xml.

The difficulty that we faced was we cannot import any packages rather than the packages set which are imported by default. So get the date and the time without using java.util was a big challenge.

Using Code Assist (similar to IntelliSense in Visual Studio) I found the below class and methods which can cater the above file name generation requirement.

 com.infor.ecutil.util.DateTimeConverter c = new DateTimeConverter();  
 String fileName = "MyFileName." + c.getEDIDateTime()+""+c.getEDIDateTime("TS")+".xml";  

"TS" => the Format Qualifier

I've found the below Format Qualifies in Phillip Kuo's blog.

It seems X12 and EDIFACT are fairly equivalent regarding dates.
An example of the newer X12 standards for dates would be Data Element 1250
and how it defines the next element; 1251 (The actual date being reported).

Some of the valid values for DE1250 are:

CC – First two digits of the year expressed in the format CCYY (length of 2)
CM – Date in Format CCYYMM (length of 6)
CY – Year Expressed in Format CCYY (length of 4)
D6 – Complete Date expressed in the format YYMMDD (length of 6)
D8 – Complete Date expressed in the format CCYYMMDD (length of 8)
DB – Date Expressed in Format MMDDCYY
DD – Day of Month in Numeric Format (length of 2)
DT – Date and Time Expressed in Format CCYYMMDDHHMM (length of 12)
MD – Month of Year and Day of Month in Format MMDD (length of 4)
MM – Month of Year in Numeric Format (length of 2)
TM – Time Expressed in Format HHMM (length of 4)
TS – Time Expressed in Format HHMMSS (length of 6)
YM – Year and Month Expressed in Format YYMM (length of 4)
YY – Last two digits of Year Expressed in Format CCYY (length of 2)
RD2 – Range of Years Expressed in Format YY-YY (length of 5)
RD4 – Range of Years Expressed in Format CCYY-CCYY (length of 9)
RD5 – Range of Years and Months Expressed in Format CCYYMM-CCYYMM (length of 13)
RD6 – Range of Dates Expressed in Format YYMMDD-YYMMDD (length of 13)
RD8 – Range of Dates Expressed in Format CCYYMMDD-CCYYMMDD (length of 17)
RDM – Range of Dates Expressed in Format YYMMDD-MMDD (length of 11)
RDT – Range of Date and Time, Expressed in Format CCYYMMDDHHMM-CCYYMMDDHHMM (length of 25)
RMD – Range of Months and Days Expressed in format MMDD-MMDD (length of 9)
RTM – Range of Time Expressed in Format HHMM-HHMM (length of 9)

DE1251 is a 35 byte alpha-numeric field.

No comments:

Post a Comment