Class BaseDateTime
- All Implemented Interfaces:
Serializable,Comparable<ReadableInstant>,ReadableDateTime,ReadableInstant
- Direct Known Subclasses:
DateMidnight,DateTime,MutableDateTime
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
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an instance set to the current system millisecond time usingISOChronologyin the default time zone.BaseDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) Constructs an instance from datetime field values usingISOChronologyin 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 usingISOChronologyin the specified time zone.BaseDateTime(long instant) Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z usingISOChronologyin 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 usingISOChronologyin 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.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 usingISOChronologyin the specified time zone. -
Method Summary
Modifier and TypeMethodDescriptionGets the chronology of the datetime.longGets 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, toStringMethods 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, toStringMethods inherited from interface java.lang.Comparable
compareToMethods 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
-
Constructor Details
-
BaseDateTime
public BaseDateTime()Constructs an instance set to the current system millisecond time usingISOChronologyin the default time zone. -
BaseDateTime
Constructs an instance set to the current system millisecond time usingISOChronologyin 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
Constructs an instance set to the current system millisecond time using the specified chronology.If the chronology is null,
ISOChronologyin 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 usingISOChronologyin the default time zone.- Parameters:
instant- the milliseconds from 1970-01-01T00:00:00Z
-
BaseDateTime
Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z usingISOChronologyin 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:00Zzone- the time zone, null means default zone
-
BaseDateTime
Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z using the specified chronology.If the chronology is null,
ISOChronologyin the default time zone is used.- Parameters:
instant- the milliseconds from 1970-01-01T00:00:00Zchronology- the chronology, null means ISOChronology in default zone
-
BaseDateTime
Constructs an instance from an Object that represents a datetime, forcing the time zone to that specified.If the object contains no chronology,
ISOChronologyis used. If the specified time zone is null, the default zone is used.The recognised object types are defined in
ConverterManagerand include ReadableInstant, String, Calendar and Date.- Parameters:
instant- the datetime objectzone- the time zone- Throws:
IllegalArgumentException- if the instant is invalid
-
BaseDateTime
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
ConverterManagerand include ReadableInstant, String, Calendar and Date.- Parameters:
instant- the datetime objectchronology- 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 usingISOChronologyin the default time zone.- Parameters:
year- the yearmonthOfYear- the month of the yeardayOfMonth- the day of the monthhourOfDay- the hour of the dayminuteOfHour- the minute of the hoursecondOfMinute- the second of the minutemillisOfSecond- 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 usingISOChronologyin the specified time zone.If the specified time zone is null, the default zone is used.
- Parameters:
year- the yearmonthOfYear- the month of the yeardayOfMonth- the day of the monthhourOfDay- the hour of the dayminuteOfHour- the minute of the hoursecondOfMinute- the second of the minutemillisOfSecond- the millisecond of the secondzone- 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,
ISOChronologyin the default time zone is used.- Parameters:
year- the yearmonthOfYear- the month of the yeardayOfMonth- the day of the monthhourOfDay- the hour of the dayminuteOfHour- the minute of the hoursecondOfMinute- the second of the minutemillisOfSecond- the millisecond of the secondchronology- the chronology, null means ISOChronology in default zone
-
-
Method Details
-
getMillis
public long getMillis()Gets the milliseconds of the datetime instant from the Java epoch of 1970-01-01T00:00:00Z.- Specified by:
getMillisin interfaceReadableInstant- Returns:
- the number of milliseconds since 1970-01-01T00:00:00Z
-
getChronology
Gets the chronology of the datetime.- Specified by:
getChronologyin interfaceReadableInstant- Returns:
- the Chronology that the datetime is using
-