Methods | This Package | All Packages

DateDataFormat Class

Represents a data format object for formatting date data types.

DataFormat
  |
  +--DateDataFormat

package com.ms.wfc.data

public class DateDataFormat
extends
DataFormat
implements
IConstructable

Remarks

The Column and DataBinding classes provide a dataFormat property, which allows you to format numerical, date, or boolean values. For example, if a column in a DataGrid control contains dates or times, you can set its dataFormat property to a DateDataFormat object:

import com.ms.wfc.data.*;
import com.ms.wfc.data.ui.*;

/* Retrieve a date-valued column in a DataGrid control.
   Assume this column has an index of 1 in the grid. */
Column column1 = dataGrid1.getColumn(1);

/* Format the column by setting its dataFormat
   property. Create a DateDataFormat object and
   use the default Short Date format. */
column1.setDataFormat(new DateDataFormat());

The DateDataFormat class provides two properties to format date and time values:

Property Description
format Specifies the type of format, using one of the constants from the DateFormat class. The default value of this property is DateFormat.SHORT, which specifies the Short Date format.
customFormat Specifies a custom format string, which is used only when the format property is set to DateFormat.CUSTOM.

The following example shows how to use these properties to change the initial format of the column:

/* Retrieve the column's current DateDataFormat object. */
DateDataFormat dFormat = (DateDataFormat) column1.getDataFormat();

/* Set the DateDataFormat object's format property
   to DateFormat.CUSTOM and set the customFormat
   property to a custom string. */ 
dFormat.setFormat(DateFormat.CUSTOM);
dFormat.setCustomFormat("mm/dd/yyyy");

For information about formatting date or time values in the Forms Designer, see Formatting Data.

See Also   BooleanDataFormat, NumberDataFormat