Hi,
I have created a physical file with the following DDS:
A R DUMMY01
A FIELD00 12P 5
A FIELD01 12S 0
A FIELD02 50A
A FIELD03 4B
A FIELD04 4F
A FIELD05 T
A FIELD06 Z
A FIELD07 L
I need to identify the type of the field. I tried
AS400FileRecordDescription fd = new AS400FileRecordDescription(system, "/QSYS.LIB/MSCHMIDT.LIB/TESTFILE.FILE");
RecordFormat[] recordFormats = fd.retrieveRecordFormat();
for (RecordFormat recordFormat : recordFormats) {
System.out.println(recordFormat.getName());
FieldDescription[] fds = recordFormat.getFieldDescriptions();
for (FieldDescription ifd : fds) {
System.out.println(ifd.getFieldName() + ": " + ifd.getDataType().getInstanceType() + " - " + ifd.getDataType().getJavaType().getSimpleName());
}
}
Everything works but the FIELD05 (Time), FIELD06 (Timestamp) and FIELD07 (Date) are only recognized as text fields with the data type 9 = AS400DataType.TYPE_TEXT.
How do I identify fields of type date, time or timestamp?
Best regards
Mihael
You can check the file field description with following command to check if it is correct or not as Toolbox read from this.
DSPFFD FILE(MSCHMIDT/TESTFILE)
I will try on my system.
I reproduce on my system, and investigating.
Originally FieldDescription for date, time or timestamp is set with AS400Text, so you always get type of String. I will update it to AS400Date, AS400Time, AS400Timestamp in future release. If a test jar is needed now, just let me know then.
It is not critical for my application. I can wait till the next release. Thank you.
Sorry to say that the updates are not made in jtopen 9.0 as after investigation, the data type changing has impacts on some situation. The difference of java and ibm i date time format, make it string type more suitable to keep the value. I will take more consideration about the type changing, not impacting on any existing apps.
BTW, you can judge the FieldDescription whether DateFieldDescription etc instance or not to determin.