Reference

Essential Classes

java.util.Calendar

Preferred method of dealing with dates. Instantiate with

  Calendar cal = Calendar.getInstance();

To change the value of a field of a Calendar object one of use,

  cal.set(int field, int value);
  cal.add(int field, int amount);
  cal.roll(int field, int value);

To specify a specific date use,

  cal.set(int year, int month, int day, int hour, int minute, int second);

To determine the value of a specific date part of a date,

  int i = get(int field);

To convert to the Date class,

  Date d = cal.getTime();

API for the java.util.Calendar package

java.util.Enumeration

An object that implements the Enumeration interface generates a series of elements, one at a time. Successive calls to the nextElement() method return successive elements of the series.

  Enumeration e = v.elements;
  while(e.hasMoreElements())
  {
    System.out.println(e.nextElement());
  }

API for the java.util.Enumeration package

java.util.StringTokenizer

The StringTokenizer class allows an application to break a string into tokens. The following code,

  StringTokenizer st = new StringTokenizer("this is a test");
  while(st.hasMoreTokens())
  {
    System.out.println(st.nextToken());
  }

prints the following output:

  this
  is
  a
  test

API for the java.util.StringTokenizer package