toString()

Return the date in a specified format or the default format.

Syntax

public String toString()
 public String toString(String format)
 public String toString(String format boolean twelveHr) 
 

Parameters

format
The date format. See DtpDate() for more details.
twelveHr
A boolean that, if set to true, specifies that the method returns 12-hour time instead of 24-hour time.

Return values

A string containing the date information, such as:

19990930 053029 PM
 

Regardless of the format of the month position, the output string is always a 2 character integer representation (that is, 01 for January, 12 for December, and so forth).

Exceptions

DtpDateException - When the date format is invalid.

Examples

try
    {
    DtpDate toDay = new DtpDate();
    String date = toDay.toString("Y/M/D h:m:s");
    }
 catch ( DtpDateException date_e )
    {
    System.out.println(date_e.getMessage());
    }
 
 

Copyright IBM Corp. 2003