org.modeshape.graph.property.basic
Class JodaDateTime

java.lang.Object
  extended by org.modeshape.graph.property.basic.JodaDateTime
All Implemented Interfaces:
Serializable, Comparable<DateTime>, DateTime

@Immutable
public class JodaDateTime
extends Object
implements DateTime

Implementation of DateTime based upon the Joda-Time library.

See Also:
Serialized Form

Constructor Summary
JodaDateTime()
           
JodaDateTime(Calendar jdkCalendar)
           
JodaDateTime(Date jdkDate)
           
JodaDateTime(org.joda.time.DateTime dateTime)
           
JodaDateTime(org.joda.time.DateTimeZone dateTimeZone)
           
JodaDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisecondsOfSecond)
           
JodaDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisecondsOfSecond, org.joda.time.Chronology chronology)
           
JodaDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisecondsOfSecond, org.joda.time.DateTimeZone dateTimeZone)
           
JodaDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisecondsOfSecond, int timeZoneOffsetHours)
           
JodaDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisecondsOfSecond, String timeZoneId)
           
JodaDateTime(long milliseconds)
           
JodaDateTime(long milliseconds, org.joda.time.Chronology chronology)
           
JodaDateTime(long milliseconds, String timeZoneId)
           
JodaDateTime(String iso8601)
           
JodaDateTime(String iso8601, String timeZoneId)
           
 
Method Summary
 int compareTo(DateTime that)
          
 boolean equals(Object obj)
          
 int getCenturyOfEra()
          Get the era of this instance in time.
 int getDayOfMonth()
          Get the day of the month value of this instance in time.
 int getDayOfWeek()
          Get the day of the week value of this instance in time.
 int getDayOfYear()
          Get the day of the year of this instance in time.
 int getEra()
          Get the era of this instance in time.
 int getHourOfDay()
          Get the hour of the day of this instance in time.
 long getMilliseconds()
          Get the number of milliseconds from 1970-01-01T00:00Z.
 long getMillisecondsInUtc()
          Get the number of milliseconds from 1970-01-01T00:00Z with this time converted to UTC.
 int getMillisOfSecond()
          Get the milliseconds of the second value of this instance in time.
 int getMinuteOfHour()
          Get the minute of this instance in time.
 int getMonthOfYear()
          Get the month of the year of this instance in time.
 int getSecondOfMinute()
          Get the seconds of the minute value of this instance in time.
 String getString()
          Get the ISO-8601 representation of this instance in time.
 String getTimeZoneId()
          Get the identifier of the time zone in which this instant is defined
 int getTimeZoneOffsetHours()
          Get the number of hours that this time zone is offset from UTC.
 int getWeekOfWeekyear()
          Get the week of the weekyear of this instance in time.
 int getWeekyear()
          Get the era of this instance in time.
 int getYear()
          Get the era of this instance in time.
 int getYearOfCentury()
          Get the year of this century of this instance in time.
 int getYearOfEra()
          Get the year of the era of this instance in time.
 int hashCode()
          
 boolean isAfter(DateTime other)
          Return whether this date-time is later than the supplied date-time.
 boolean isBefore(DateTime other)
          Return whether this date-time is earlier than the supplied date-time.
 boolean isSameAs(DateTime other)
          Return whether this date-time is exactly the the same as the supplied date-time.
 DateTime minus(long timeAmount, TimeUnit unit)
          Subtract the specified about of time in the supplied units.
 DateTime minusDays(int days)
          Subtract the specified number of days from this time instant.
 DateTime minusHours(int hours)
          Subtract the specified number of hours from this time instant.
 DateTime minusMillis(int milliseconds)
          Subtract the specified number of milliseconds from this time instant.
 DateTime minusMinutes(int minutes)
          Subtract the specified number of minutes from this time instant.
 DateTime minusMonths(int months)
          Subtract the specified number of months from this time instant.
 DateTime minusSeconds(int seconds)
          Subtract the specified number of seconds from this time instant.
 DateTime minusWeeks(int weeks)
          Subtract the specified number of weeks from this time instant.
 DateTime minusYears(int years)
          Subtract the specified number of years from this time instant.
 DateTime plus(long timeAmount, TimeUnit unit)
          Add the specified about of time in the supplied units.
 DateTime plusDays(int days)
          Add the specified number of days from this time instant.
 DateTime plusHours(int hours)
          Add the specified number of hours from this time instant.
 DateTime plusMillis(int milliseconds)
          Add the specified number of milliseconds from this time instant.
 DateTime plusMinutes(int minutes)
          Add the specified number of minutes from this time instant.
 DateTime plusMonths(int months)
          Add the specified number of months from this time instant.
 DateTime plusSeconds(int seconds)
          Add the specified number of seconds from this time instant.
 DateTime plusWeeks(int weeks)
          Add the specified number of weeks from this time instant.
 DateTime plusYears(int years)
          Add the specified number of years from this time instant.
 Calendar toCalendar()
          Get this instance represented as a standard JDK Calendar instance, in the default locale.
 Calendar toCalendar(Locale locale)
          Get this instance represented as a standard JDK Calendar instance, in the specified locale .
 Date toDate()
          Get this instance represented as a standard JDK Date instance.
 GregorianCalendar toGregorianCalendar()
          Get this instance represented as a standard JDK GregorianCalendar instance.
 String toString()
          
 DateTime toTimeZone(String timeZoneId)
          Convert this time to the time zone given by the supplied identifier.
 DateTime toUtcTimeZone()
          Convert this time to the same instant in the UTC time zone.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JodaDateTime

public JodaDateTime()

JodaDateTime

public JodaDateTime(String iso8601)

JodaDateTime

public JodaDateTime(String iso8601,
                    String timeZoneId)

JodaDateTime

public JodaDateTime(long milliseconds)

JodaDateTime

public JodaDateTime(long milliseconds,
                    org.joda.time.Chronology chronology)

JodaDateTime

public JodaDateTime(long milliseconds,
                    String timeZoneId)

JodaDateTime

public JodaDateTime(org.joda.time.DateTimeZone dateTimeZone)

JodaDateTime

public JodaDateTime(int year,
                    int monthOfYear,
                    int dayOfMonth,
                    int hourOfDay,
                    int minuteOfHour,
                    int secondOfMinute,
                    int millisecondsOfSecond)

JodaDateTime

public JodaDateTime(int year,
                    int monthOfYear,
                    int dayOfMonth,
                    int hourOfDay,
                    int minuteOfHour,
                    int secondOfMinute,
                    int millisecondsOfSecond,
                    org.joda.time.Chronology chronology)

JodaDateTime

public JodaDateTime(int year,
                    int monthOfYear,
                    int dayOfMonth,
                    int hourOfDay,
                    int minuteOfHour,
                    int secondOfMinute,
                    int millisecondsOfSecond,
                    org.joda.time.DateTimeZone dateTimeZone)

JodaDateTime

public JodaDateTime(int year,
                    int monthOfYear,
                    int dayOfMonth,
                    int hourOfDay,
                    int minuteOfHour,
                    int secondOfMinute,
                    int millisecondsOfSecond,
                    int timeZoneOffsetHours)

JodaDateTime

public JodaDateTime(int year,
                    int monthOfYear,
                    int dayOfMonth,
                    int hourOfDay,
                    int minuteOfHour,
                    int secondOfMinute,
                    int millisecondsOfSecond,
                    String timeZoneId)

JodaDateTime

public JodaDateTime(Date jdkDate)

JodaDateTime

public JodaDateTime(Calendar jdkCalendar)

JodaDateTime

public JodaDateTime(org.joda.time.DateTime dateTime)
Method Detail

getCenturyOfEra

public int getCenturyOfEra()
Get the era of this instance in time.

Specified by:
getCenturyOfEra in interface DateTime
Returns:
the era

getDayOfMonth

public int getDayOfMonth()
Get the day of the month value of this instance in time.

Specified by:
getDayOfMonth in interface DateTime
Returns:
the day of the month

getDayOfWeek

public int getDayOfWeek()
Get the day of the week value of this instance in time.

Specified by:
getDayOfWeek in interface DateTime
Returns:
the day of the week

getDayOfYear

public int getDayOfYear()
Get the day of the year of this instance in time.

Specified by:
getDayOfYear in interface DateTime
Returns:
the day of the year

getEra

public int getEra()
Get the era of this instance in time.

Specified by:
getEra in interface DateTime
Returns:
the era

getHourOfDay

public int getHourOfDay()
Get the hour of the day of this instance in time.

Specified by:
getHourOfDay in interface DateTime
Returns:
the hour of the day

getMillisOfSecond

public int getMillisOfSecond()
Get the milliseconds of the second value of this instance in time.

Specified by:
getMillisOfSecond in interface DateTime
Returns:
the milliseconds

getMilliseconds

public long getMilliseconds()
Get the number of milliseconds from 1970-01-01T00:00Z. This value is consistent with the JDK Date and Calendar classes.

Specified by:
getMilliseconds in interface DateTime
Returns:
the number of milliseconds from 1970-01-01T00:00Z

getMillisecondsInUtc

public long getMillisecondsInUtc()
Get the number of milliseconds from 1970-01-01T00:00Z with this time converted to UTC. This value is consistent with the JDK Date and Calendar classes.

Specified by:
getMillisecondsInUtc in interface DateTime
Returns:
the number of milliseconds from 1970-01-01T00:00Z in the UTC time zone
See Also:
DateTime.getMillisecondsInUtc()

getMinuteOfHour

public int getMinuteOfHour()
Get the minute of this instance in time.

Specified by:
getMinuteOfHour in interface DateTime
Returns:
the minute of the hour

getMonthOfYear

public int getMonthOfYear()
Get the month of the year of this instance in time.

Specified by:
getMonthOfYear in interface DateTime
Returns:
the month number

getSecondOfMinute

public int getSecondOfMinute()
Get the seconds of the minute value of this instance in time.

Specified by:
getSecondOfMinute in interface DateTime
Returns:
the seconds of the minute

getString

public String getString()
Get the ISO-8601 representation of this instance in time. The month-based ISO-8601 representation is the most common format of ISO8601, and is the format used in the XML standards for passing dates and times:
 yyyy-mm-ddTHH:MM:SS.SSSZ
 
The fields are separated by dashes and consist of:

Specified by:
getString in interface DateTime
Returns:
the string representation; never null

getWeekOfWeekyear

public int getWeekOfWeekyear()
Get the week of the weekyear of this instance in time.

Specified by:
getWeekOfWeekyear in interface DateTime
Returns:
the week of the weekyear

getWeekyear

public int getWeekyear()
Get the era of this instance in time.

Specified by:
getWeekyear in interface DateTime
Returns:
the era

getYear

public int getYear()
Get the era of this instance in time.

Specified by:
getYear in interface DateTime
Returns:
the era

getYearOfCentury

public int getYearOfCentury()
Get the year of this century of this instance in time.

Specified by:
getYearOfCentury in interface DateTime
Returns:
the year of the century

getYearOfEra

public int getYearOfEra()
Get the year of the era of this instance in time.

Specified by:
getYearOfEra in interface DateTime
Returns:
the year of the era

getTimeZoneOffsetHours

public int getTimeZoneOffsetHours()
Get the number of hours that this time zone is offset from UTC.

Specified by:
getTimeZoneOffsetHours in interface DateTime
Returns:
the number of hours

getTimeZoneId

public String getTimeZoneId()
Get the identifier of the time zone in which this instant is defined

Specified by:
getTimeZoneId in interface DateTime
Returns:
the time zone identifier; never null

toCalendar

public Calendar toCalendar()
Get this instance represented as a standard JDK Calendar instance, in the default locale.

Specified by:
toCalendar in interface DateTime
Returns:
this instance in time as a JDK Calendar; never null

toCalendar

public Calendar toCalendar(Locale locale)
Get this instance represented as a standard JDK Calendar instance, in the specified locale .

Specified by:
toCalendar in interface DateTime
Parameters:
locale - the locale in which the Calendar instance is desired; may be null if the default locale is to be used.
Returns:
this instance in time as a JDK Calendar; never null

toDate

public Date toDate()
Get this instance represented as a standard JDK Date instance. Note that this conversion loses the time zone information, as the standard JDK Date does not represent time zones.

Specified by:
toDate in interface DateTime
Returns:
this instance in time as a JDK Date; never null

toGregorianCalendar

public GregorianCalendar toGregorianCalendar()
Get this instance represented as a standard JDK GregorianCalendar instance.

Specified by:
toGregorianCalendar in interface DateTime
Returns:
this instance in time as a JDK GregorianCalendar; never null

compareTo

public int compareTo(DateTime that)

Specified by:
compareTo in interface Comparable<DateTime>

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

toString

public String toString()

Overrides:
toString in class Object

toUtcTimeZone

public DateTime toUtcTimeZone()
Convert this time to the same instant in the UTC time zone.

Specified by:
toUtcTimeZone in interface DateTime
Returns:
this instant in time in the specified time zone

toTimeZone

public DateTime toTimeZone(String timeZoneId)
Convert this time to the time zone given by the supplied identifier.

Specified by:
toTimeZone in interface DateTime
Parameters:
timeZoneId - the time zone identifier
Returns:
the instant in the specified time zone

isBefore

public boolean isBefore(DateTime other)
Return whether this date-time is earlier than the supplied date-time.

Specified by:
isBefore in interface DateTime
Parameters:
other - the date-time to compare with
Returns:
true if this date-time is earliar than the other, or false otherwise
See Also:
DateTime.isBefore(org.modeshape.graph.property.DateTime)

isSameAs

public boolean isSameAs(DateTime other)
Return whether this date-time is exactly the the same as the supplied date-time. This differs from the equals method in that it can be arbitrarily more strict, checking, for example, not only the logical equivalence of the other date time, but also arbitrary additional fields such as the time zone.

Specified by:
isSameAs in interface DateTime
Parameters:
other - the date-time to compare with
Returns:
true if this date-time is later than the other, or false otherwise
See Also:
DateTime.isSameAs(org.modeshape.graph.property.DateTime)

isAfter

public boolean isAfter(DateTime other)
Return whether this date-time is later than the supplied date-time.

Specified by:
isAfter in interface DateTime
Parameters:
other - the date-time to compare with
Returns:
true if this date-time is later than the other, or false otherwise
See Also:
DateTime.isAfter(org.modeshape.graph.property.DateTime)

minus

public DateTime minus(long timeAmount,
                      TimeUnit unit)
Subtract the specified about of time in the supplied units.

Specified by:
minus in interface DateTime
Parameters:
timeAmount - the amount of time to subtract
unit - the units of the amount of time; may not be null
Returns:
the instance in time the specified number of time before this instant
See Also:
DateTime.minus(long, java.util.concurrent.TimeUnit)

minusDays

public DateTime minusDays(int days)
Subtract the specified number of days from this time instant.

Specified by:
minusDays in interface DateTime
Parameters:
days - the number of days to subtract
Returns:
the instance in time the specified number of days before this instant
See Also:
DateTime.minusDays(int)

minusHours

public DateTime minusHours(int hours)
Subtract the specified number of hours from this time instant.

Specified by:
minusHours in interface DateTime
Parameters:
hours - the number of hours to subtract
Returns:
the instance in time the specified number of hours before this instant
See Also:
DateTime.minusHours(int)

minusMillis

public DateTime minusMillis(int milliseconds)
Subtract the specified number of milliseconds from this time instant.

Specified by:
minusMillis in interface DateTime
Parameters:
milliseconds - the number of milliseconds to subtract
Returns:
the instance in time the specified number of milliseconds before this instant
See Also:
DateTime.minusMillis(int)

minusMinutes

public DateTime minusMinutes(int minutes)
Subtract the specified number of minutes from this time instant.

Specified by:
minusMinutes in interface DateTime
Parameters:
minutes - the number of minutes to subtract
Returns:
the instance in time the specified number of minutes before this instant
See Also:
DateTime.minusMinutes(int)

minusMonths

public DateTime minusMonths(int months)
Subtract the specified number of months from this time instant.

Specified by:
minusMonths in interface DateTime
Parameters:
months - the number of months to subtract
Returns:
the instance in time the specified number of months before this instant
See Also:
DateTime.minusMonths(int)

minusSeconds

public DateTime minusSeconds(int seconds)
Subtract the specified number of seconds from this time instant.

Specified by:
minusSeconds in interface DateTime
Parameters:
seconds - the number of seconds to subtract
Returns:
the instance in time the specified number of seconds before this instant
See Also:
DateTime.minusSeconds(int)

minusWeeks

public DateTime minusWeeks(int weeks)
Subtract the specified number of weeks from this time instant.

Specified by:
minusWeeks in interface DateTime
Parameters:
weeks - the number of weeks to subtract
Returns:
the instance in time the specified number of weeks before this instant
See Also:
DateTime.minusWeeks(int)

minusYears

public DateTime minusYears(int years)
Subtract the specified number of years from this time instant.

Specified by:
minusYears in interface DateTime
Parameters:
years - the number of years to subtract
Returns:
the instance in time the specified number of years before this instant
See Also:
DateTime.minusYears(int)

plus

public DateTime plus(long timeAmount,
                     TimeUnit unit)
Add the specified about of time in the supplied units.

Specified by:
plus in interface DateTime
Parameters:
timeAmount - the amount of time to add
unit - the units of the amount of time; may not be null
Returns:
the instance in time the specified number of time after this instant
See Also:
DateTime.plus(long, java.util.concurrent.TimeUnit)

plusDays

public DateTime plusDays(int days)
Add the specified number of days from this time instant.

Specified by:
plusDays in interface DateTime
Parameters:
days - the number of days to add
Returns:
the instance in time the specified number of days after this instant
See Also:
DateTime.plusDays(int)

plusHours

public DateTime plusHours(int hours)
Add the specified number of hours from this time instant.

Specified by:
plusHours in interface DateTime
Parameters:
hours - the number of hours to add
Returns:
the instance in time the specified number of hours after this instant
See Also:
DateTime.plusHours(int)

plusMillis

public DateTime plusMillis(int milliseconds)
Add the specified number of milliseconds from this time instant.

Specified by:
plusMillis in interface DateTime
Parameters:
milliseconds - the number of milliseconds to add
Returns:
the instance in time the specified number of milliseconds after this instant
See Also:
DateTime.plusMillis(int)

plusMinutes

public DateTime plusMinutes(int minutes)
Add the specified number of minutes from this time instant.

Specified by:
plusMinutes in interface DateTime
Parameters:
minutes - the number of minutes to add
Returns:
the instance in time the specified number of minutes after this instant
See Also:
DateTime.plusMinutes(int)

plusMonths

public DateTime plusMonths(int months)
Add the specified number of months from this time instant.

Specified by:
plusMonths in interface DateTime
Parameters:
months - the number of months to add
Returns:
the instance in time the specified number of months after this instant
See Also:
DateTime.plusMonths(int)

plusSeconds

public DateTime plusSeconds(int seconds)
Add the specified number of seconds from this time instant.

Specified by:
plusSeconds in interface DateTime
Parameters:
seconds - the number of seconds to add
Returns:
the instance in time the specified number of seconds after this instant
See Also:
DateTime.plusSeconds(int)

plusWeeks

public DateTime plusWeeks(int weeks)
Add the specified number of weeks from this time instant.

Specified by:
plusWeeks in interface DateTime
Parameters:
weeks - the number of weeks to add
Returns:
the instance in time the specified number of weeks after this instant
See Also:
DateTime.plusWeeks(int)

plusYears

public DateTime plusYears(int years)
Add the specified number of years from this time instant.

Specified by:
plusYears in interface DateTime
Parameters:
years - the number of years to add
Returns:
the instance in time the specified number of years after this instant
See Also:
DateTime.plusYears(int)


Copyright © 2008-2010 JBoss, a division of Red Hat. All Rights Reserved.