Yes. The Java text
and util
packages have classes
DateFormat
, Calendar
, and Date
which have many features for dealing with dates and times.
But let us ignore that and write our own class, MyDate
.
This example shows how to create an object
based on an input string.
Here is our complete MyDate
class:
class MyDate { int day, month, year; MyDate ( int d, int m, int y ) { day = d; month = m; year = y; } public String toString() { return day + "/" + month + "/" + year ; } }
Does this class have "getter" and "setter" methods?