com.ibm.as400.access
Class DateTimeConverter

java.lang.Object
  extended bycom.ibm.as400.access.DateTimeConverter

public class DateTimeConverter
extends Object

The DateTimeConverter class represents a converted date and time. The system API QWCCVTDT is used to convert a date and time value from one format to another format.


Constructor Summary
DateTimeConverter(AS400 system)
          Constructs a DateTimeConverter object.
 
Method Summary
 Date convert(byte[] data, String inFormat)
          Returns a converted Date object.
 byte[] convert(byte[] data, String inFormat, String outFormat)
          Converts date and time values from the input format to the requested output format.
 byte[] convert(Date date, String outFormat)
          Returns the converted date and time in a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateTimeConverter

public DateTimeConverter(AS400 system)
Constructs a DateTimeConverter object.

Parameters:
system - The system.
Method Detail

convert

public byte[] convert(byte[] data,
                      String inFormat,
                      String outFormat)
               throws AS400SecurityException,
                      ErrorCompletingRequestException,
                      InterruptedException,
                      IOException,
                      ObjectDoesNotExistException
Converts date and time values from the input format to the requested output format.

This method effectively re-arranges the time format and returns it. Therefore, no adjustments are made based on time-zone.

Parameters:
data - The date and time value to be converted.
inFormat - The input date and time format. Possible values are:
  • *CURRENT
  • *DTS
  • *JOB
  • *SYSVAL
  • *YMD
  • *YYMD
  • *MDY
  • *MDYY
  • *DMY
  • *DMYY
  • *JUL
  • *LONGJUL
outFormat - The output date and time format. Possible values are:
  • *DTS
  • *JOB
  • *SYSVAL
  • *YMD
  • *YYMD
  • *MDY
  • *MDYY
  • *DMY
  • *DMYY
  • *JUL
  • *LONGJUL
  • *DOS
Returns:
The converted date and time value.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.

convert

public Date convert(byte[] data,
                    String inFormat)
             throws AS400SecurityException,
                    ErrorCompletingRequestException,
                    InterruptedException,
                    IOException,
                    ObjectDoesNotExistException
Returns a converted Date object.

Note: This method does not change the time-zone setting in the returned Date object.

Note: When *CURRENT is specified, the data parameter will not be used. The time will be retrieved from the AS400 system object and adjusted to the local time-zone based on the value returned from TimeZone.getDefault().getOffset() for the client.

Parameters:
data - The date and time value to be converted.
inFormat - The format of the date and time value being provided. Possible values are:
  • *CURRENT
  • *DTS
  • *JOB
  • *SYSVAL
  • *YMD
  • *YYMD
  • *MDY
  • *MDYY
  • *DMY
  • *DMYY
  • *JUL
  • *LONGJUL
Returns:
The converted date and time.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.

convert

public byte[] convert(Date date,
                      String outFormat)
               throws AS400SecurityException,
                      ErrorCompletingRequestException,
                      InterruptedException,
                      IOException,
                      ObjectDoesNotExistException
Returns the converted date and time in a byte array.

Parameters:
date - The Date object to be converted.
outFormat - The format of the returned date and time value. Possible values are:
  • *DTS
  • *JOB
  • *SYSVAL
  • *YMD
  • *YYMD
  • *MDY
  • *MDYY
  • *DMY
  • *DMYY
  • *JUL
  • *LONGJUL
Returns:
The converted date and time.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.