This class handles conversion to and from the X12 Time data type to the schema language time data type based on ISO 8601. The differences in representation are shown earlier in the chapter in Table 9.6.
Logic for the DataCellX12TM fromXML Method
Arguments:
None
Returns:
Error status or throws exception
IF Buffer Length < 8
Return error
ENDIF
Hours <- Cell Buffer characters at offsets 0 and 1
Minutes <- Cell Buffer characters at offsets 3 and 4
Seconds <- Cell Buffer characters at offsets 6 and 7
Fractional Seconds <- Cell Buffer characters 9 and beyond,
if present
Cell Buffer <- Hours + Minutes + Seconds + Fractional Seconds
Buffer Length <- String length of Cell Buffer
Return success
Logic for the DataCellX12TM toXML Method
Arguments:
None
Returns:
Error status or throws exception
Cell Buffer < trim leading and trailing whitespace from
Cell Buffer
IF Buffer Length < 4
Return error
ENDIF
Hours <- Cell Buffer characters at offsets 0 and 1
Minutes <- Cell Buffer characters at offsets 2 and 3
Seconds <- Cell Buffer characters at offsets 4 and 5, if present,
otherwise "00"
Fractional Seconds <- Cell Buffer characters 6 and beyond
if present
Cell Buffer <- Hours + ":" + Minutes + ":" + Seconds + "."
+ Fractional Seconds
Buffer Length <- String length of Cell Buffer
Return success
The prepareOutput method truncates the data if required. We will somewhat arbitrarily assume that if the X12 target data element is not large enough to handle seconds or fractions of a second, users will not mind if we discard them.
Logic for the DataCellX12TM prepareOutput Method
Arguments:
None
Returns:
Status or throws exception
Maximum Length <- Call Grammar Element's getAttribute for
"MaxLength"
IF Buffer Length > Maximum Length
Truncate Cell Buffer from left to Maximum Length
Buffer Length <- Maximum Length
Return success