Package bank
Class Calendar
java.lang.Object
bank.Calendar
Calendar class for keeping the current date and compute date intervals. Dates
are represented as the number of days from 1970/01/01.
-
Method Summary
Modifier and TypeMethodDescriptionvoidadvanceDate(int days)Advance today's date by a given number of days.intdaysSince(long before)static CalendargetDate(long date)voidsetDate(int year, int month, int day)Set today's date (for debug purposes only).voidsetDate(long date)Set today's date (for debug purposes only).longtoday()toString()
-
Method Details
-
getCalendar
- Returns:
- the single instance of this class.
-
today
public long today()- Returns:
- number of days since 1979/01/01.
-
daysSince
public int daysSince(long before)- Parameters:
before- a previous date- Returns:
- number of days from "before" to the today.
-
getDate
- Parameters:
date- number of days from 1970/01/01.- Returns:
- string representing a date with the format AAAA MM DD.
-
setDate
public void setDate(long date)Set today's date (for debug purposes only).- Parameters:
date- number of days from 1970/01/01.
-
advanceDate
public void advanceDate(int days)Advance today's date by a given number of days.- Parameters:
days-
-
setDate
public void setDate(int year, int month, int day)Set today's date (for debug purposes only).- Parameters:
year- today's year.month- today's month (starts at 1).day- today's day.
-
toString
- Overrides:
toStringin classObject- See Also:
Object.toString()
-