org.onebusaway.gtfs.model.calendar
Class ServiceDate

java.lang.Object
  extended by org.onebusaway.gtfs.model.calendar.ServiceDate
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<ServiceDate>

public class ServiceDate
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable<ServiceDate>

A general representation of a year-month-day tuple not tied to any locale and used by the GTFS entities ServiceCalendar and ServiceCalendarDate to represent service date ranges. A service date is a particular date when a particular GTFS service id is active.

Author:
bdferris
See Also:
Serialized Form

Constructor Summary
ServiceDate()
           
ServiceDate(java.util.Calendar calendar)
           
ServiceDate(java.util.Date date)
          Construct a ServiceDate from the specified Date object, using the default TimeZone object for the current VM to localize the date
ServiceDate(int year, int month, int day)
          Construct a new ServiceDate by specifying the numeric year, month, and day
ServiceDate(ServiceDate o)
           
 
Method Summary
 int compareTo(ServiceDate o)
           
 boolean equals(java.lang.Object obj)
           
 java.util.Date getAsDate()
           
 java.util.Date getAsDate(java.util.TimeZone timeZone)
          Constructs a Date object such that the Date will be at "midnight" (12:00am) at the start of the day specified by this service date and the target timezone.
 java.lang.String getAsString()
           
 int getDay()
           
 int getMonth()
           
 int getYear()
           
 int hashCode()
           
static ServiceDate parseString(java.lang.String value)
          Parse a service date from a string in "YYYYMMDD" format.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServiceDate

public ServiceDate(int year,
                   int month,
                   int day)
Construct a new ServiceDate by specifying the numeric year, month, and day

Parameters:
year - - numeric year (ex. 2010)
month - - numeric month of the year, where Jan = 1, Feb = 2, etc
day - - numeric day of month

ServiceDate

public ServiceDate(ServiceDate o)

ServiceDate

public ServiceDate(java.util.Calendar calendar)

ServiceDate

public ServiceDate(java.util.Date date)
Construct a ServiceDate from the specified Date object, using the default TimeZone object for the current VM to localize the date

Parameters:
date -

ServiceDate

public ServiceDate()
Method Detail

parseString

public static ServiceDate parseString(java.lang.String value)
Parse a service date from a string in "YYYYMMDD" format.

Parameters:
value - a string of the form "YYYYMMDD"
Returns:
a new ServiceDate object

getYear

public int getYear()

getMonth

public int getMonth()

getDay

public int getDay()

getAsDate

public java.util.Date getAsDate()
Returns:
calls getAsDate(TimeZone) with the default timezone for this VM

getAsDate

public java.util.Date getAsDate(java.util.TimeZone timeZone)
Constructs a Date object such that the Date 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.

Parameters:
timeZone - the target timezone to localize the service date to
Returns:
a localized date at "midnight" at the start of this service date in the specified timezone

getAsString

public java.lang.String getAsString()
Returns:
a string in "YYYYMMDD" format

compareTo

public int compareTo(ServiceDate o)
Specified by:
compareTo in interface java.lang.Comparable<ServiceDate>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


Copyright © 2010 OneBusAway. All Rights Reserved.