Using time within an EJB

Time is a complex topic with many aspects of time being beyond the scope of this book. Within this recipe, we will examine several common problems that can occur when working with time in a Java EE application.

Getting ready

To use time in a Java application we normally use a Date instance in conjunction with a Calendar instance. The Date object represents a time while the Calendar instance maps it to a specific calendar system.

Normally we will use the DateFormat or a DateFormat derived class to convert a time into a string for display purposes. While the use of these classes appears straightforward, there are several areas where a developer can go astray.

Time is represented using an instance of the Date class. However, ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.