Lecture 12
Lecture 12
-color: String
-filled: boolean
Circle Rectangle
-radius: double -width: double
-height: double
+Circle ()
+Circle (radius: double) +Rectangle()
1 2
3 4
1
11/14/2016
5 6
7 8
2
11/14/2016
The Abstract Calendar Class and Its The Abstract Calendar Class and Its
GregorianCalendar subclass GregorianCalendar subclass
java.util.Calendar • An instance of java.util.Date represents a specific
#Calendar() Constructs a default calendar.
+get(field: int): int Returns the value of the given calendar field. instant in time with millisecond precision.
+set(field: int, value: int): void Sets the given calendar to the specified value.
+set(year: int, month: int, Sets the calendar with the specified year, month, and date. The month • java.util.Calendar is an abstract base class for
dayOfMonth: int): void parameter is 0-based, that is, 0 is for January.
+getActualMaximum(field: int): int Returns the maximum value that the specified calendar field could have. extracting detailed information such as year, month,
+add(field: int, amount: int): void Adds or subtracts the specified amount of time to the given calendar field.
+getTime(): java.util.Date Returns a Date object representing this calendar’s time value (million
date, hour, minute and second from a Date object.
second offset from the Unix epoch).
+setTime(date: java.util.Date): void Sets this calendar’s time with the given Date object. • Subclasses of Calendar can implement specific
java.util.GregorianCalendar
calendar systems such as Gregorian calendar, Lunar
+GregorianCalendar() Constructs a GregorianCalendar for the current time. Calendar and Jewish calendar.
+GregorianCalendar(year: int, Constructs a GregorianCalendar for the specified year, month, and day of
month: int, dayOfMonth: int)
+GregorianCalendar(year: int,
month.
Constructs a GregorianCalendar for the specified year, month, day of
• Currently, java.util.GregorianCalendar for the
month: int, dayOfMonth: int,
hour:int, minute: int, second: int)
month, hour, minute, and second. The month parameter is 0-based, that
is, 0 is for January.
Gregorian calendar is supported in the Java API.
9 10
11