org.joda.time.base
Class AbstractDateTime
- Comparable, ReadableDateTime, ReadableInstant
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.
- Brian S O'Neill
- Stephen Colebourne
compareTo , equals , get , 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 |
AbstractDateTime
protected AbstractDateTime()
Constructor.
get
public int get(DateTimeFieldType type)
Get the value of one of the fields of a datetime.
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 interface AbstractInstant
type
- a field type, usually obtained from DateTimeFieldType
getWeekyear
public int getWeekyear()
Get the weekyear field value.
- getWeekyear in interface ReadableDateTime
- the year of a week based year
toCalendar
public Calendar toCalendar(Locale locale)
Get the date time as a
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
- a localized Calendar initialised with this datetime
toGregorianCalendar
public GregorianCalendar toGregorianCalendar()
Get the date time as a
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.
- a GregorianCalendar initialised with this datetime
toString
public String toString(String pattern)
Output the instant using the specified format pattern.
- toString in interface ReadableDateTime
pattern
- the pattern specification, null means use toString
toString
public String toString(String pattern,
Locale locale)
throws IllegalArgumentException
Output the instant using the specified format pattern.
- toString in interface ReadableDateTime
pattern
- the pattern specification, null means use toString
locale
- Locale to use, null means default
Copyright (c) 2001-2006 - Joda.org