public final class Day extends Object
The length of the day depends on the trading schedule and other circumstances. For example, it is possible that day for Monday is longer than 24 hours because it includes part of Sunday; consequently, the day for Sunday will be shorter than 24 hours to avoid overlapping with Monday.
Days do not overlap with each other - rather they form consecutive chain of adjacent periods of time that cover entire time scale. The point on a border line is considered to belong to following day that starts there.
Each day consists of sessions that cover entire duration of the day. If day contains at least one trading session (i.e. session within which trading activity is allowed), then the day is considered trading day. Otherwise the day is considered non-trading day (e.g. weekend or holiday).
Day may contain sessions with zero duration - e.g. indices that post value once a day. Such sessions can be of any appropriate type, trading or non-trading. Day may have zero duration as well - e.g. when all time within it is transferred to other days.
Modifier and Type | Method and Description |
---|---|
boolean |
containsTime(long time)
Returns
true if specified time belongs to this day. |
boolean |
equals(Object object) |
Session |
findFirstSession(SessionFilter filter)
Returns first session belonging to this day accepted by specified filter.
|
Session |
findLastSession(SessionFilter filter)
Returns last session belonging to this day accepted by specified filter.
|
Day |
findNextDay(DayFilter filter)
Returns following day accepted by specified filter.
|
Day |
findPrevDay(DayFilter filter)
Returns previous day accepted by specified filter.
|
int |
getDayId()
Number of this day since January 1, 1970 (that day has identifier of 0 and previous days have negative identifiers).
|
int |
getDayOfMonth()
Returns ordinal day number in the month starting with 1 for the first day of month.
|
int |
getDayOfWeek()
Returns ordinal day number in the week starting with 1=Monday and ending with 7=Sunday.
|
long |
getEndTime()
Returns end time of this day (exclusive).
|
Session |
getFirstSession(SessionFilter filter)
Returns first session belonging to this day accepted by specified filter.
|
Session |
getLastSession(SessionFilter filter)
Returns last session belonging to this day accepted by specified filter.
|
int |
getMonthOfYear()
Returns calendar month number in the year starting with 1=January and ending with 12=December.
|
Day |
getNextDay(DayFilter filter)
Returns following day accepted by specified filter.
|
Day |
getPrevDay(DayFilter filter)
Returns previous day accepted by specified filter.
|
long |
getResetTime()
Returns reset time for this day.
|
Schedule |
getSchedule()
Returns schedule to which this day belongs.
|
Session |
getSessionByTime(long time)
Returns session belonging to this day that contains specified time.
|
List<Session> |
getSessions()
Returns list of sessions that constitute this day.
|
long |
getStartTime()
Returns start time of this day (inclusive).
|
int |
getYear()
Returns calendar year - i.e.
|
int |
getYearMonthDay()
Returns year, month and day numbers decimally packed in the following way:
|
int |
hashCode() |
boolean |
isHoliday()
Returns
true if this day is an exchange holiday. |
boolean |
isShortDay()
Returns
true if this day is a short day. |
boolean |
isTrading()
Returns
true if trading activity is allowed within this day. |
String |
toString() |
public Schedule getSchedule()
public int getDayId()
public int getYearMonthDay()
YearMonthDay = year * 10000 + month * 100 + dayFor example, September 28, 1977 has value 19770928.
public int getYear()
1977
for the year 1977
.public int getMonthOfYear()
public int getDayOfMonth()
public int getDayOfWeek()
public boolean isHoliday()
true
if this day is an exchange holiday.
Usually there are no trading takes place on an exchange holiday.public boolean isShortDay()
true
if this day is a short day.
Usually trading stops earlier on a short day.public boolean isTrading()
true
if trading activity is allowed within this day.
Positive result assumes that day has at least one trading session.public long getStartTime()
public long getEndTime()
public boolean containsTime(long time)
true
if specified time belongs to this day.public long getResetTime()
public List<Session> getSessions()
public Session getSessionByTime(long time)
NoSuchElementException
.time
- the time to search forNoSuchElementException
- if no such session was found within this daypublic Session getFirstSession(SessionFilter filter)
NoSuchElementException
.
To find first trading session of any type use this code:
Session session = day.getFirstSession(SessionFilter.TRADING);To find first regular trading session use this code:
Session session = day.getFirstSession(SessionFilter.REGULAR);
filter
- the filter to test sessionsNoSuchElementException
- if no such session was found within this daypublic Session getLastSession(SessionFilter filter)
NoSuchElementException
.
To find last trading session of any type use this code:
Session session = day.getLastSession(SessionFilter.TRADING);To find last regular trading session use this code:
Session session = day.getLastSession(SessionFilter.REGULAR);
filter
- the filter to test sessionsNoSuchElementException
- if no such session was found within this daypublic Session findFirstSession(SessionFilter filter)
To find first trading session of any type use this code:
Session session = day.findFirstSession(SessionFilter.TRADING);To find first regular trading session use this code:
Session session = day.findFirstSession(SessionFilter.REGULAR);
filter
- the filter to test sessionspublic Session findLastSession(SessionFilter filter)
To find last trading session of any type use this code:
Session session = day.findLastSession(SessionFilter.TRADING);To find last regular trading session use this code:
Session session = day.findLastSession(SessionFilter.REGULAR);
filter
- the filter to test sessionspublic Day getPrevDay(DayFilter filter)
NoSuchElementException
.filter
- the filter to test daysNoSuchElementException
- if no such day was found within one yearpublic Day getNextDay(DayFilter filter)
NoSuchElementException
.filter
- the filter to test daysNoSuchElementException
- if no such day was found within one yearpublic Day findPrevDay(DayFilter filter)
filter
- the filter to test dayspublic Day findNextDay(DayFilter filter)
filter
- the filter to test daysCopyright © 2002–2023 Devexperts LLC. All rights reserved.