|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.joda.time.base.AbstractInstant org.joda.time.base.AbstractDateTime
public abstract class AbstractDateTime
AbstractDateTime provides the common behaviour for datetime classes.
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.
Whenever you want to implement ReadableDateTime
you should
extend this class.
AbstractDateTime subclasses may be mutable and not thread-safe.
Constructor Summary | |
---|---|
protected |
AbstractDateTime()
Constructor. |
Method Summary | |
---|---|
int |
get(DateTimeFieldType type)
Get the value of one of the fields of a datetime. |
int |
getCenturyOfEra()
Get the year of era field value. |
int |
getDayOfMonth()
Get the day of month field value. |
int |
getDayOfWeek()
Get the day of week field value. |
int |
getDayOfYear()
Get the day of year field value. |
int |
getEra()
Get the era field value. |
int |
getHourOfDay()
Get the hour of day field value. |
int |
getMillisOfDay()
Get the millis of day field value. |
int |
getMillisOfSecond()
Get the millis of second field value. |
int |
getMinuteOfDay()
Get the minute of day field value. |
int |
getMinuteOfHour()
Get the minute of hour field value. |
int |
getMonthOfYear()
Get the month of year field value. |
int |
getSecondOfDay()
Get the second of day field value. |
int |
getSecondOfMinute()
Get the second of minute field value. |
int |
getWeekOfWeekyear()
Get the week of weekyear field value. |
int |
getWeekyear()
Get the weekyear field value. |
int |
getYear()
Get the year field value. |
int |
getYearOfCentury()
Get the year of century field value. |
int |
getYearOfEra()
Get the year of era field value. |
Calendar |
toCalendar(Locale locale)
Get the date time as a java.util.Calendar , assigning
exactly the same millisecond instant. |
GregorianCalendar |
toGregorianCalendar()
Get the date time as a java.util.GregorianCalendar ,
assigning exactly the same millisecond instant. |
String |
toString(String pattern)
Output the instant using the specified format pattern. |
String |
toString(String pattern,
Locale locale)
Output the instant using the specified format pattern. |
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 |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.joda.time.ReadableDateTime |
---|
toDateTime, toMutableDateTime |
Methods inherited from interface org.joda.time.ReadableInstant |
---|
equals, getChronology, getMillis, getZone, hashCode, isAfter, isBefore, isEqual, isSupported, toInstant, toString |
Methods inherited from interface java.lang.Comparable |
---|
compareTo |
Constructor Detail |
---|
protected AbstractDateTime()
Method Detail |
---|
public int get(DateTimeFieldType type)
This method uses the chronology of the datetime to obtain the value. It is essentially a generic way of calling one of the get methods.
get
in interface ReadableInstant
get
in class AbstractInstant
type
- a field type, usually obtained from DateTimeFieldType
IllegalArgumentException
- if the field type is nullpublic int getEra()
getEra
in interface ReadableDateTime
public int getCenturyOfEra()
getCenturyOfEra
in interface ReadableDateTime
public int getYearOfEra()
getYearOfEra
in interface ReadableDateTime
public int getYearOfCentury()
getYearOfCentury
in interface ReadableDateTime
public int getYear()
getYear
in interface ReadableDateTime
public int getWeekyear()
The weekyear is the year that matches with the weekOfWeekyear field. In the standard ISO8601 week algorithm, the first week of the year is that in which at least 4 days are in the year. As a result of this definition, day 1 of the first week may be in the previous year. The weekyear allows you to query the effective year for that day.
getWeekyear
in interface ReadableDateTime
public int getMonthOfYear()
getMonthOfYear
in interface ReadableDateTime
public int getWeekOfWeekyear()
This field is associated with the "weekyear" via getWeekyear()
.
In the standard ISO8601 week algorithm, the first week of the year
is that in which at least 4 days are in the year. As a result of this
definition, day 1 of the first week may be in the previous year.
getWeekOfWeekyear
in interface ReadableDateTime
public int getDayOfYear()
getDayOfYear
in interface ReadableDateTime
public int getDayOfMonth()
The values for the day of month are defined in DateTimeConstants
.
getDayOfMonth
in interface ReadableDateTime
public int getDayOfWeek()
The values for the day of week are defined in DateTimeConstants
.
getDayOfWeek
in interface ReadableDateTime
public int getHourOfDay()
getHourOfDay
in interface ReadableDateTime
public int getMinuteOfDay()
getMinuteOfDay
in interface ReadableDateTime
public int getMinuteOfHour()
getMinuteOfHour
in interface ReadableDateTime
public int getSecondOfDay()
getSecondOfDay
in interface ReadableDateTime
public int getSecondOfMinute()
getSecondOfMinute
in interface ReadableDateTime
public int getMillisOfDay()
getMillisOfDay
in interface ReadableDateTime
public int getMillisOfSecond()
getMillisOfSecond
in interface ReadableDateTime
public Calendar toCalendar(Locale locale)
java.util.Calendar
, assigning
exactly the same millisecond instant.
The locale is passed in, enabling Calendar to select the correct
localized subclass.
The JDK and Joda-Time both have time zone implementations and these
differ in accuracy. Joda-Time's implementation is generally more up to
date and thus more accurate - for example JDK1.3 has no historical data.
The effect of this is that the field values of the Calendar
may differ from those of this object, even though the milliseond value
is the same. Most of the time this just means that the JDK field values
are wrong, as our time zone information is more up to date.
locale
- the locale to get the Calendar for, or default if null
public GregorianCalendar toGregorianCalendar()
java.util.GregorianCalendar
,
assigning exactly the same millisecond instant.
The JDK and Joda-Time both have time zone implementations and these
differ in accuracy. Joda-Time's implementation is generally more up to
date and thus more accurate - for example JDK1.3 has no historical data.
The effect of this is that the field values of the Calendar
may differ from those of this object, even though the milliseond value
is the same. Most of the time this just means that the JDK field values
are wrong, as our time zone information is more up to date.
public String toString(String pattern)
toString
in interface ReadableDateTime
pattern
- the pattern specification, null means use toString
DateTimeFormat
public String toString(String pattern, Locale locale) throws IllegalArgumentException
toString
in interface ReadableDateTime
pattern
- the pattern specification, null means use toString
locale
- Locale to use, null means default
IllegalArgumentException
- if pattern is invalidDateTimeFormat
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |