public class ServiceDate extends Object implements Serializable, Comparable<ServiceDate>
ServiceCalendar
and
ServiceCalendarDate
to represent service date ranges. A service date
is a particular date when a particular GTFS service id is active.Constructor and Description |
---|
ServiceDate() |
ServiceDate(Calendar calendar) |
ServiceDate(Date date)
|
ServiceDate(int year,
int month,
int day)
Construct a new ServiceDate by specifying the numeric year, month, and day
|
ServiceDate(ServiceDate o) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(ServiceDate o) |
long |
difference(ServiceDate serviceDate) |
boolean |
equals(Object obj) |
Calendar |
getAsCalendar(TimeZone timeZone)
Constructs a
Calendar object such that the Calendar will be at
"midnight" (12:00am) at the start of the day specified by this service date
and the target timezone. |
Date |
getAsDate() |
Date |
getAsDate(TimeZone timeZone)
See
getAsCalendar(TimeZone) for more details. |
String |
getAsString() |
int |
getDay() |
int |
getMonth() |
int |
getYear() |
int |
hashCode() |
static void |
moveCalendarToServiceDate(Calendar c)
Adjust the supplied
Calendar object such that the calendar will be
at "midnight" (12:00am) at the start of the day specified by the current
calendar date and locale. |
ServiceDate |
next() |
static ServiceDate |
parseString(String value)
Parse a service date from a string in "YYYYMMDD" format.
|
ServiceDate |
previous() |
ServiceDate |
shift(int numberOfDays) |
String |
toString() |
public ServiceDate(int year, int month, int day)
year
- - numeric year (ex. 2010)month
- - numeric month of the year, where Jan = 1, Feb = 2, etcday
- - numeric day of monthpublic ServiceDate(ServiceDate o)
public ServiceDate(Calendar calendar)
public ServiceDate(Date date)
Date
object, using the
default TimeZone
object for the current VM to localize the datedate
- public ServiceDate()
public static ServiceDate parseString(String value) throws ParseException
value
- a string of the form "YYYYMMDD"ParseException
- on parse errorpublic int getYear()
public int getMonth()
public int getDay()
public Date getAsDate()
getAsDate(TimeZone)
with the default timezone for
this VMpublic Calendar getAsCalendar(TimeZone timeZone)
Calendar
object such that the Calendar will be at
"midnight" (12:00am) at the start of the day specified by this service date
and the target timezone. Note that we take the GTFS convention of
calculating midnight by setting the target date to noon (12:00pm) for the
service date and timezone specified and then subtracting twelve hours.
Normally that would be equivalent to midnight, except on Daylight Saving
Time days, in which case it can be an hour ahead or behind. This behavior
ensures correct calculation of StopTime
arrival and departure time
when the second offset is added to the localized service date.timeZone
- the target timezone to localize the service date topublic Date getAsDate(TimeZone timeZone)
getAsCalendar(TimeZone)
for more details.timeZone
- the target timezone to localize the service date topublic String getAsString()
public ServiceDate next()
public ServiceDate previous()
public ServiceDate shift(int numberOfDays)
numberOfDays
- public long difference(ServiceDate serviceDate)
serviceDate
- public int compareTo(ServiceDate o)
compareTo
in interface Comparable<ServiceDate>
public static void moveCalendarToServiceDate(Calendar c)
Calendar
object such that the calendar will be
at "midnight" (12:00am) at the start of the day specified by the current
calendar date and locale. Note that we take the GTFS convention of
calculating midnight by setting the target date to noon (12:00pm) for the
service date and timezone specified and then subtracting twelve hours.
Normally that would be equivalent to midnight, except on Daylight Saving
Time days, in which case it can be an hour ahead or behind. This behavior
ensures correct calculation of StopTime
arrival and departure time
when the second offset is added to the localized service date.c
- the target calendar, already to some time on the target dateCopyright © 2019. All rights reserved.