Working with dates and times

You can display the current date or time in a data table, or elsewhere in your Web application.

  1. Set up a value for the date or time by using the java.sql.Date or java.sql.Timestamp classes in the Quick Edit view.

  2. Drag an Output component from the Faces Components drawer to the appropriate column of your data table.

  3. In the Properties view for the Output component, enter the relevant data source in the Value field and set other style attributes.

  4. Make sure that Date/Time is selected as the format (it should be selected based on the data source you entered in the Value field in the previous step). You can also set other Date/Time attributes, such as the type (for example, Date only) and the style for the date or time (for example, Jul 23, 2004).

Example: the following snippet reads the current date/time and puts it to the data source's DATEOPEN property, which is then mapped to the TIMESTAMP column

  ...

Calendar rightNow = Calendar.getInstance();
ad.put("DATEOPEN",rightNow.getTime());

  ...

Drag an Output component from the palette to the data table. Then fill in the following properties in the Properties view for the Output component:

 

Related concepts

Faces components
Data table components

 

Related tasks

Creating Faces applications - overview
Adding a data table

Related reference
Faces components reference
Faces attributes reference