Basic HTML version of Foils prepared 17 Nov 97

Foil 20 The Date class

From Java Tutorial, July 1, 1996 CEWES Tutorial, CPS606, JSU Class CSC499 -- July 22-25 1997, Fall 97. by Nancy J. McCracken,Geoffrey C. Fox, Tom Scavo


This class provides an implementation of "date" structures. Date has methods to create and compare dates, obtain and set the time, and convert dates to strings.
The Date constructor creates today's date:
Date today = new Date();
In Java 1.1, most Date methods have been deprecated in favor of the Calendar class:
Calendar date1 = Calendar.getInstance();
date1.set( 999, 12, 31 ); /* Dec. 31, 999 */
Calendar date2 = Calendar.getInstance();
date2.set( 1996, 12, 31, 23, 59, 59 )
    • /* Dec.31,1996 at 23:59:59 */



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998