Posted By:
AlessandroA_Garbagnati
Posted On:
Tuesday, April 8, 2003 01:43 AM
Hi,
you are probably referring to
java.text.DateFormat, that is, as specified in the javadoc that I suggest you to read, an abstract class for displaying or reading a date value to and from a string.
...
// create a DateFormat object
DateFormat df = new SimpleDateFormat("MMM dd, yyyy HH:mm:ss");
// format a date to get a formatted string
System.out.println(df.format(new Date());
// gets a date object from a formatted string
String dateStr = "Dec 21, 1966 17:10:00";
Date myDate = df.parse(dateStr);
...
//
// this code doesn't have any error control...
//
java.util.Calendar, as specified in the javadoc that I suggest you to read, is an Abstract class that has replaced some functionality of the Date class, to improve the conversion between date fields (day, week, month, hour, etc.) to integer values. The
java.util.GregorianCalendar class, as specified in the javadoc that I suggest you to read, is a concrete subclass of the Calendar class.
...
Calendar cal = new CregorianCalendar();
// or = Calendar.getInstance();
int month = cal.get(Calendar.MONTH);
int minute = cal.get(Calendar.MINUTE);
...
In both cases, I will suggest you to read the javadoc, because they provide all additional information regarding Calendar constants and DateFormat symbols.