|
Venice 0.7beta | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.mov.util.TradingDate
public class TradingDate
A replacement date for java.util.Date, java.util.Calendar & java.sql.Date. The main principles of this date class are speed (as fast as possible) and size (as small as possible). It produces a much smaller and faster date class than using the Calendar hierarchy. It also beats java.util.Date by not using deprecated methods.
| Field Summary | |
|---|---|
static int |
BRITISH
Date format will be in britsh format, e.g. |
static int |
US
Date format will be in US format, e.g. |
| Constructor Summary | |
|---|---|
TradingDate()
Create a new date set to today. |
|
TradingDate(java.util.Calendar date)
Create a new date from the given java.util.Calendar object. |
|
TradingDate(java.util.Date date)
Create a new date from the given java.util.Date object. |
|
TradingDate(int year,
int month,
int day)
Create a new date from the given year, month and day. |
|
TradingDate(java.lang.String date,
int type)
Create a new date from the given string. |
|
| Method Summary | |
|---|---|
boolean |
after(java.lang.Object date)
Tests if this date is after the specified date. |
boolean |
before(java.lang.Object date)
Tests if this date is before the specified date. |
java.lang.Object |
clone()
Create a clone of this date |
int |
compareTo(java.lang.Object date)
Compare the current date to the specified object. |
int |
compareTo(TradingDate date)
Compare this date to the specified date. |
static java.util.List |
dateRangeToList(TradingDate startDate,
TradingDate endDate)
Convert a start and end date to a list of all the trading dates inbetween which do not fall on weekends. |
boolean |
equals(java.lang.Object date)
Compares this date with the specified object. |
int |
getDay()
Return the day of the month. |
int |
getDayOfWeek()
Return the day of the week. |
int |
getDayOfYear()
Return the day of the year. |
int |
getMonth()
Return the month. |
int |
getYear()
Return the year. |
int |
hashCode()
Create a fast hash code of this date |
boolean |
isWeekend()
Return whether the current date falls on a weekend. |
static java.lang.String |
monthToText(int month)
Convert a month number to its 3 digit name. |
TradingDate |
next(int days)
Create a new date which is the specified number of trading days after this date. |
TradingDate |
previous(int days)
Create a new date which is the specified number of trading days before this date. |
java.util.Calendar |
toCalendar()
Convert this object to a java.util.Calendar. |
java.util.Date |
toDate()
Convert this object to a java.util.Date. |
java.util.Date |
toDate(TradingTime time)
Convert this object and a TradingTime to a java.util.Date. |
java.lang.String |
toLongString()
Outputs date in the format - 30 Dec, 2001. |
java.lang.String |
toShortString()
Outputs the date in the format - 12/Dec. |
java.lang.String |
toString()
Outputs the date in the following format 1/12/2005 or 31/12/2005. |
java.lang.String |
toString(java.lang.String format)
Convert date to string in specified format. |
static int |
twoToFourDigitYear(int year)
Converts a two digit year to four digit year. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int US
mm/dd/yy, mm/dd/yyyy
etc.
public static final int BRITISH
dd/mm/yy, dd/mm/yyyy
etc.
| Constructor Detail |
|---|
public TradingDate(int year,
int month,
int day)
year - a four digit year, e.g. 1996month - the month starting from 1day - the day starting from 1public TradingDate(java.util.Calendar date)
java.util.Calendar object.
date - calendar date to convertpublic TradingDate(java.util.Date date)
java.util.Date object.
date - the date to convert
public TradingDate(java.lang.String date,
int type)
throws TradingDateFormatException
YYMMDD | e.g. "010203" |
YYYYMMDD | e.g. "20010203" |
DD/MM/YY | e.g. "3/2/01" |
DD/MM/YYYY | e.g. "3/2/2001" |
MM/DD/YY | e.g. "2/3/01" |
MM/DD/YYYY | e.g. "2/3/2001" |
DD-MM-YY | e.g. "3-2-01" |
DD-MM-YYYY | e.g. "3-2-2001" |
MM-DD-YY | e.g. "2-3-01" |
MM-DD-YYYY | e.g. "2-3-2001" |
DD/MONTH/YY | e.g. "3/Feb/01" |
DD/MONTH/YYYY | e.g. "3/Feb/2001" |
DD-MONTH-YY | e.g. "3-February-01" |
DD-MONTH-YYYY | e.g. "3-February-2001" |
date - the date string to parsetype - either BRITISH or US
TradingDateException - if the date couldn't be parsed
TradingDateFormatExceptionpublic TradingDate()
| Method Detail |
|---|
public int getYear()
public int getMonth()
public int getDay()
public int getDayOfWeek()
public int getDayOfYear()
public boolean before(java.lang.Object date)
date - the specified date to compare
true if the given date is before this onepublic boolean after(java.lang.Object date)
date - the specified date to compare
true if the specified date is before this one;
false otherwise.public boolean equals(java.lang.Object date)
equals in class java.lang.Objectdate - the specified date to compare
true if the specified date is equal;
false otherwise.public java.lang.Object clone()
clone in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic TradingDate previous(int days)
days - the number of days to move
days before the current onepublic TradingDate next(int days)
days - the number of days to move
days after the current onepublic boolean isWeekend()
true if the current date is on a weekend.public int compareTo(java.lang.Object date)
compareTo in interface java.lang.ComparablecompareTo(TradingDate)public int compareTo(TradingDate date)
date - the date to compare
0 if the dates are equal;
1 if this date is after the specified date or
-1 if this date is before the specified date.public java.lang.String toString(java.lang.String format)
d? | Replaced with one or two digit day |
dd | Replaced with two digit day |
m? | Replaced with one or two digit month |
mm | Replaced with two digit month |
MMM | Replaced with 3 letter month name |
yy | Replaced with two digit year |
yyyy | Replaced with four digit year |
E.g.:
text = date.toString("d?-m?-yyyy");
format - the format of the string
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toShortString()
public java.lang.String toLongString()
public static java.lang.String monthToText(int month)
month - the month number
public java.util.Date toDate()
java.util.Datepublic java.util.Date toDate(TradingTime time)
TradingTime to a java.util.Date.
java.util.Datepublic java.util.Calendar toCalendar()
java.util.Calendarpublic static int twoToFourDigitYear(int year)
year - a two digit year
public static java.util.List dateRangeToList(TradingDate startDate,
TradingDate endDate)
startDate - the start date of the rangeendDate - the end date of the range
|
Venice 0.7beta | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||