org.joda.time.base
Class BaseDateTime

java.lang.Object
  extended byorg.joda.time.base.AbstractInstant
      extended byorg.joda.time.base.AbstractDateTime
          extended byorg.joda.time.base.BaseDateTime
All Implemented Interfaces:
Comparable, ReadableDateTime, ReadableInstant, Serializable
Direct Known Subclasses:
DateMidnight, DateTime, MutableDateTime

public abstract class BaseDateTime
extends AbstractDateTime
implements ReadableDateTime, Serializable

BaseDateTime is an abstract implementation of ReadableDateTime that stores data in long and Chronology fields.

This class should generally not be used directly by API users. The ReadableDateTime interface should be used when different kinds of date/time objects are to be referenced.

BaseDateTime subclasses may be mutable and not thread-safe.

Since:
1.0
Author:
Stephen Colebourne, Kandarp Shah, Brian S O'Neill
See Also:
Serialized Form

Constructor Summary
BaseDateTime()
          Constructs an instance set to the current system millisecond time using ISOChronology in the default time zone.
BaseDateTime(Chronology chronology)
          Constructs an instance set to the current system millisecond time using the specified chronology.
BaseDateTime(DateTimeZone zone)
          Constructs an instance set to the current system millisecond time using ISOChronology in the specified time zone.
BaseDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond)
          Constructs an instance from datetime field values using ISOChronology in the default time zone.
BaseDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond, Chronology chronology)
          Constructs an instance from datetime field values using the specified chronology.
BaseDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond, DateTimeZone zone)
          Constructs an instance from datetime field values using ISOChronology in the specified time zone.
BaseDateTime(long instant)
          Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z using ISOChronology in the default time zone.
BaseDateTime(long instant, Chronology chronology)
          Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z using the specified chronology.
BaseDateTime(long instant, DateTimeZone zone)
          Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z using ISOChronology in the specified time zone.
BaseDateTime(Object instant, Chronology chronology)
          Constructs an instance from an Object that represents a datetime, using the specified chronology.
BaseDateTime(Object instant, DateTimeZone zone)
          Constructs an instance from an Object that represents a datetime, forcing the time zone to that specified.
 
Method Summary
 Chronology getChronology()
          Gets the chronology of the datetime.
 long getMillis()
          Gets the milliseconds of the datetime instant from the Java epoch of 1970-01-01T00:00:00Z.
 
Methods inherited from class org.joda.time.base.AbstractDateTime
get, getCenturyOfEra, getDayOfMonth, getDayOfWeek, getDayOfYear, getEra, getHourOfDay, getMillisOfDay, getMillisOfSecond, getMinuteOfDay, getMinuteOfHour, getMonthOfYear, getSecondOfDay, getSecondOfMinute, getWeekOfWeekyear, getWeekyear, getYear, getYearOfCentury, getYearOfEra, toCalendar, toGregorianCalendar, toString, toString
 
Methods inherited from class org.joda.time.base.AbstractInstant
compareTo, equals, get, getZone, hashCode, isAfter, isAfter, isAfterNow, isBefore, isBefore, isBeforeNow, isEqual, isEqual, isEqualNow, isSupported, toDate, toDateTime, toDateTime, toDateTime, toDateTimeISO, toInstant, toMutableDateTime, toMutableDateTime, toMutableDateTime, toMutableDateTimeISO, toString, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.joda.time.ReadableDateTime
getCenturyOfEra, getDayOfMonth, getDayOfWeek, getDayOfYear, getEra, getHourOfDay, getMillisOfDay, getMillisOfSecond, getMinuteOfDay, getMinuteOfHour, getMonthOfYear, getSecondOfDay, getSecondOfMinute, getWeekOfWeekyear, getWeekyear, getYear, getYearOfCentury, getYearOfEra, toDateTime, toMutableDateTime, toString, toString
 
Methods inherited from interface org.joda.time.ReadableInstant
compareTo, equals, get, getZone, hashCode, isAfter, isBefore, isEqual, isSupported, toInstant, toString
 

Constructor Detail

BaseDateTime

public BaseDateTime()
Constructs an instance set to the current system millisecond time using ISOChronology in the default time zone.


BaseDateTime

public BaseDateTime(DateTimeZone zone)
Constructs an instance set to the current system millisecond time using ISOChronology in the specified time zone.

If the specified time zone is null, the default zone is used.

Parameters:
zone - the time zone, null means default zone

BaseDateTime

public BaseDateTime(Chronology chronology)
Constructs an instance set to the current system millisecond time using the specified chronology.

If the chronology is null, ISOChronology in the default time zone is used.

Parameters:
chronology - the chronology, null means ISOChronology in default zone

BaseDateTime

public BaseDateTime(long instant)
Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z using ISOChronology in the default time zone.

Parameters:
instant - the milliseconds from 1970-01-01T00:00:00Z

BaseDateTime

public BaseDateTime(long instant,
                    DateTimeZone zone)
Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z using ISOChronology in the specified time zone.

If the specified time zone is null, the default zone is used.

Parameters:
instant - the milliseconds from 1970-01-01T00:00:00Z
zone - the time zone, null means default zone

BaseDateTime

public BaseDateTime(long instant,
                    Chronology chronology)
Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z using the specified chronology.

If the chronology is null, ISOChronology in the default time zone is used.

Parameters:
instant - the milliseconds from 1970-01-01T00:00:00Z
chronology - the chronology, null means ISOChronology in default zone

BaseDateTime

public BaseDateTime(Object instant,
                    DateTimeZone zone)
Constructs an instance from an Object that represents a datetime, forcing the time zone to that specified.

If the object contains no chronology, ISOChronology is used. If the specified time zone is null, the default zone is used.

The recognised object types are defined in ConverterManager and include ReadableInstant, String, Calendar and Date.

Parameters:
instant - the datetime object
zone - the time zone
Throws:
IllegalArgumentException - if the instant is invalid

BaseDateTime

public BaseDateTime(Object instant,
                    Chronology chronology)
Constructs an instance from an Object that represents a datetime, using the specified chronology.

If the chronology is null, ISO in the default time zone is used.

The recognised object types are defined in ConverterManager and include ReadableInstant, String, Calendar and Date.

Parameters:
instant - the datetime object
chronology - the chronology
Throws:
IllegalArgumentException - if the instant is invalid

BaseDateTime

public BaseDateTime(int year,
                    int monthOfYear,
                    int dayOfMonth,
                    int hourOfDay,
                    int minuteOfHour,
                    int secondOfMinute,
                    int millisOfSecond)
Constructs an instance from datetime field values using ISOChronology in the default time zone.

Parameters:
year - the year
monthOfYear - the month of the year
dayOfMonth - the day of the month
hourOfDay - the hour of the day
minuteOfHour - the minute of the hour
secondOfMinute - the second of the minute
millisOfSecond - the millisecond of the second

BaseDateTime

public BaseDateTime(int year,
                    int monthOfYear,
                    int dayOfMonth,
                    int hourOfDay,
                    int minuteOfHour,
                    int secondOfMinute,
                    int millisOfSecond,
                    DateTimeZone zone)
Constructs an instance from datetime field values using ISOChronology in the specified time zone.

If the specified time zone is null, the default zone is used.

Parameters:
year - the year
monthOfYear - the month of the year
dayOfMonth - the day of the month
hourOfDay - the hour of the day
minuteOfHour - the minute of the hour
secondOfMinute - the second of the minute
millisOfSecond - the millisecond of the second
zone - the time zone, null means default time zone

BaseDateTime

public BaseDateTime(int year,
                    int monthOfYear,
                    int dayOfMonth,
                    int hourOfDay,
                    int minuteOfHour,
                    int secondOfMinute,
                    int millisOfSecond,
                    Chronology chronology)
Constructs an instance from datetime field values using the specified chronology.

If the chronology is null, ISOChronology in the default time zone is used.

Parameters:
year - the year
monthOfYear - the month of the year
dayOfMonth - the day of the month
hourOfDay - the hour of the day
minuteOfHour - the minute of the hour
secondOfMinute - the second of the minute
millisOfSecond - the millisecond of the second
chronology - the chronology, null means ISOChronology in default zone
Method Detail

getMillis

public long getMillis()
Gets the milliseconds of the datetime instant from the Java epoch of 1970-01-01T00:00:00Z.

Specified by:
getMillis in interface ReadableInstant
Returns:
the number of milliseconds since 1970-01-01T00:00:00Z

getChronology

public Chronology getChronology()
Gets the chronology of the datetime.

Specified by:
getChronology in interface ReadableInstant
Returns:
the Chronology that the datetime is using


Copyright © 2002-2008 Joda.org. All Rights Reserved.