|
GeoSoft API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object Day
public final class Day
A time-less and immutable Date class for basic date arithmetics.
Constructor Summary | |
---|---|
Day()
Create a new day representing the day of creation (according to the setting of the current machine). |
|
Day(Calendar calendar)
Create a new day based on a java.util.Calendar instance. |
|
Day(Date date)
Create a new day based on a java.util.Date instance. |
|
Day(Day day)
Create a new day as a copy of the specified day. |
|
Day(int year,
int dayOfYear)
Create a new day, specifying the year and the day of year. |
|
Day(int year,
int month,
int dayOfMonth)
Create a new day. |
|
Day(long time)
Create a new day based on a time value. |
Method Summary | |
---|---|
Day |
addDays(int nDays)
Return a day which is the given number of days after this day. |
Day |
addMonths(int nMonths)
Return a day wich is a given number of month after this day. |
Day |
addYears(int nYears)
Return a day wich is a given number of years after this day. |
int |
compareTo(Day day)
Compare this day to the specified day. |
int |
daysBetween(Day day)
Return number of days between two days. |
boolean |
equals(Object object)
Return true if this day equals (represent the same date) as the specified day. |
Calendar |
getCalendar()
Return a Calendar instance representing the same day as this instance. |
Date |
getDate()
Return a Date instance representing the same date as this instance. |
String |
getDayName()
Get default locale name of this day ("Monday", "Tuesday", etc. |
int |
getDayNumberOfWeek()
Return the day number of week of this day, where Monday=1, Tuesday=2, ... |
int |
getDayOfMonth()
Return day of month of this day. |
int |
getDayOfWeek()
Return the day of week of this day. |
int |
getDayOfYear()
Return the day number of year this day represents. |
int |
getDaysInMonth()
Return the number of days in the month of this day. |
int |
getDaysInYear()
Return the number of days in the year of this day. |
static Day |
getFirstOfMonth(int dayOfWeek,
int month,
int year)
Find the first of a specific day in a given month. |
static Day |
getLastOfMonth(int dayOfWeek,
int month,
int year)
Find the last of a specific day in a given month. |
int |
getMonth()
Return month of this day. |
int |
getMonthNo()
Return the 1-based month number of the month of this day. 1 = January, 2 = February and so on. |
static Day |
getNthOfMonth(int n,
int dayOfWeek,
int month,
int year)
Find the n'th xxxxday of s specified month (for instance find 1st sunday of May 2006; findNthOfMonth (1, Calendar.SUNDAY, Calendar.MAY, 2006); Return null if the specified day doesn't exists. |
int |
getWeekOfYear()
Return the week number of year, this day belongs to. 1st=1 and so on. |
int |
getYear()
Return year of this day. |
int |
hashCode()
Overload required as default definition of equals() has changed. |
boolean |
isAfter(Day day)
Return true if this day is after the specified day. |
boolean |
isBefore(Day day)
Return true if this day is before the specified day. |
boolean |
isLeapYear()
Return true if the year of this day is a leap year. |
static boolean |
isLeapYear(int year)
Return true if the specified year is a leap year. |
static void |
main(String[] arguments)
Testing this class. |
Day |
subtractDays(int nDays)
Subtract a number of days from this day. |
Day |
subtractMonths(int nMonths)
Subtract a number of months from this day. |
Day |
subtractYears(int nYears)
Subtract a number of years from this day. |
static Day |
today()
A more explicit front-end to the Day() constructor which return a day object representing the day of creation. |
String |
toString()
Return a scratch string representation of this day. |
Methods inherited from class Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Day(int year, int month, int dayOfMonth)
year
- Year of new day.month
- Month of new day (0-11)dayOfMonth
- Day of month of new day (1-31)public Day(int year, int dayOfYear)
year
- Year of new day.dayOfYear
- 1=January 1, etc.public Day()
public Day(Calendar calendar)
calendar
- Calendar instance to copy.
IllegalArgumentException
- If calendar is null.public Day(Date date)
date
- Date instance to copy.
IllegalArgumentException
- If date is null.public Day(long time)
time
- Milliseconds since "the Epoch".public Day(Day day)
day
- Day to clone.
IllegalArgumentException
- If day is null.Method Detail |
---|
public static Day today()
public Calendar getCalendar()
public Date getDate()
public int compareTo(Day day)
compareTo
in interface Comparable<Day>
day
- Day object to compare to.
IllegalArgumentException
- If day is null.public boolean isAfter(Day day)
day
- Day to compare to.
IllegalArgumentException
- If day is null.public boolean isBefore(Day day)
day
- Day to compare to.
IllegalArgumentException
- If day is null.public boolean equals(Object object)
equals
in class Object
object
- Object to compare to.
IllegalArgumentException
- If day is null.public int hashCode()
hashCode
in class Object
public int getYear()
public int getMonth()
public int getMonthNo()
public int getDayOfMonth()
public int getDayOfYear()
public int getDayOfWeek()
public int getDayNumberOfWeek()
public int getWeekOfYear()
public Day addDays(int nDays)
nDays
- Number of days to add. May be negative.
public Day subtractDays(int nDays)
nDays
- Number of days to subtract.
public Day addMonths(int nMonths)
nMonths
- Number of months to add.
public Day subtractMonths(int nMonths)
nMonths
- Number of months to subtract.
addMonths(int).
public Day addYears(int nYears)
nYears
- Number of years to add.
public Day subtractYears(int nYears)
nYears
- Number of years to subtract.
addYears(int).
public int getDaysInYear()
public boolean isLeapYear()
public static boolean isLeapYear(int year)
year
- Year to check.
public int getDaysInMonth()
public String getDayName()
public int daysBetween(Day day)
day
- The day to compare to.
IllegalArgumentException
- If day is null.public static Day getNthOfMonth(int n, int dayOfWeek, int month, int year)
n
- Nth day to look for.dayOfWeek
- Day to look for (Calendar.XXXDAY).month
- Month to check (Calendar.XXX).year
- Year to check.
IllegalArgumentException
- if dyaOfWeek parameter
doesn't represent a valid day.public static Day getFirstOfMonth(int dayOfWeek, int month, int year)
dayOfWeek
- Weekday to get.month
- Month of day to get.year
- Year of day to get.
public static Day getLastOfMonth(int dayOfWeek, int month, int year)
dayOfWeek
- Weekday to get.month
- Month of day to get.year
- Year of day to get.
public String toString()
toString
in class Object
public static void main(String[] arguments)
arguments
- Not used.
|
GeoSoft API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |