gnu.math
Class DateTime
java.lang.Object
java.lang.Number
gnu.math.Numeric
gnu.math.Quantity
gnu.math.DateTime
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
public class DateTime
- extends Quantity
- implements java.lang.Cloneable
Represents a date and/or time.
Similar functionality as java.util.Calendar (and uses GregorianCalendar
internally) but supports arithmetic.
Can be for XML Schema date/time types, specifically as used in XPath/Xquery..
- See Also:
- Serialized Form
Constructor Summary |
DateTime(int mask)
|
DateTime(int mask,
java.util.GregorianCalendar calendar)
|
Method Summary |
static DateTime |
add(DateTime x,
Duration y,
int k)
|
Numeric |
add(java.lang.Object y,
int k)
Return this + k * obj. |
static DateTime |
addMinutes(DateTime x,
int y)
|
Numeric |
addReversed(Numeric x,
int k)
Calculate x+k&this. |
static DateTime |
addSeconds(DateTime x,
int y)
|
DateTime |
adjustTimezone(int newOffset)
|
DateTime |
cast(int newComponents)
|
static int |
compare(DateTime date1,
DateTime date2)
Return -1, 0, or 1, depending on which value is greater. |
int |
compare(java.lang.Object obj)
Return an integer for which of {# code this} or {#code obj} is larger. |
int |
components()
|
static int |
daysInMonth(int month,
int year)
|
int |
getDay()
|
int |
getHours()
|
int |
getMinutes()
|
int |
getMonth()
|
int |
getNanoSecondsOnly()
|
int |
getSecondsOnly()
|
int |
getWholeSeconds()
|
int |
getYear()
|
int |
getZoneMinutes()
|
boolean |
isExact()
|
static boolean |
isLeapYear(int year)
|
boolean |
isZero()
|
boolean |
isZoneUnspecified()
|
static java.util.TimeZone |
minutesToTimeZone(int minutes)
Get a TimeZone object for a given offset. |
Complex |
number()
|
static DateTime |
parse(java.lang.String value,
int mask)
|
void |
setTimeZone(java.util.TimeZone timeZone)
|
static Duration |
sub(DateTime date1,
DateTime date2)
|
java.lang.String |
toString()
|
void |
toString(java.lang.StringBuffer sbuf)
|
void |
toStringDate(java.lang.StringBuffer sbuf)
|
void |
toStringTime(java.lang.StringBuffer sbuf)
|
static void |
toStringZone(int minutes,
java.lang.StringBuffer sbuf)
|
void |
toStringZone(java.lang.StringBuffer sbuf)
|
Unit |
unit()
|
DateTime |
withZoneUnspecified()
|
Methods inherited from class gnu.math.Quantity |
abs, add, compare, compareReversed, dimensions, div, divide, divReversed, doubleImagValue, doubleValue, im, imValue, make, make, make, mul, mulReversed, neg, re, reValue, times, toString |
Methods inherited from class gnu.math.Numeric |
add, div_inv, equals, floatValue, geq, grt, intValue, longValue, mul_ident, power, sub |
Methods inherited from class java.lang.Number |
byteValue, shortValue |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
YEAR_MASK
public static final int YEAR_MASK
- See Also:
- Constant Field Values
MONTH_MASK
public static final int MONTH_MASK
- See Also:
- Constant Field Values
DAY_MASK
public static final int DAY_MASK
- See Also:
- Constant Field Values
HOURS_MASK
public static final int HOURS_MASK
- See Also:
- Constant Field Values
MINUTES_MASK
public static final int MINUTES_MASK
- See Also:
- Constant Field Values
SECONDS_MASK
public static final int SECONDS_MASK
- See Also:
- Constant Field Values
TIMEZONE_MASK
public static final int TIMEZONE_MASK
- See Also:
- Constant Field Values
DATE_MASK
public static final int DATE_MASK
- See Also:
- Constant Field Values
TIME_MASK
public static final int TIME_MASK
- See Also:
- Constant Field Values
GMT
public static java.util.TimeZone GMT
DateTime
public DateTime(int mask)
DateTime
public DateTime(int mask,
java.util.GregorianCalendar calendar)
components
public int components()
cast
public DateTime cast(int newComponents)
parse
public static DateTime parse(java.lang.String value,
int mask)
isLeapYear
public static boolean isLeapYear(int year)
daysInMonth
public static int daysInMonth(int month,
int year)
getYear
public int getYear()
getMonth
public int getMonth()
getDay
public int getDay()
getHours
public int getHours()
getMinutes
public int getMinutes()
getSecondsOnly
public int getSecondsOnly()
getWholeSeconds
public int getWholeSeconds()
getNanoSecondsOnly
public int getNanoSecondsOnly()
compare
public static int compare(DateTime date1,
DateTime date2)
- Return -1, 0, or 1, depending on which value is greater.
compare
public int compare(java.lang.Object obj)
- Description copied from class:
Numeric
- Return an integer for which of {# code this} or {#code obj} is larger.
Return 1 if
this>obj
; 0 if this==obj
;
-1 if this<obj
;
-2 if this!=obj
otherwise (for example if either is NaN);
-3 if not comparable (incompatible types).
- Overrides:
compare
in class Quantity
sub
public static Duration sub(DateTime date1,
DateTime date2)
withZoneUnspecified
public DateTime withZoneUnspecified()
adjustTimezone
public DateTime adjustTimezone(int newOffset)
add
public static DateTime add(DateTime x,
Duration y,
int k)
addMinutes
public static DateTime addMinutes(DateTime x,
int y)
addSeconds
public static DateTime addSeconds(DateTime x,
int y)
add
public Numeric add(java.lang.Object y,
int k)
- Description copied from class:
Numeric
- Return this + k * obj.
- Overrides:
add
in class Quantity
addReversed
public Numeric addReversed(Numeric x,
int k)
- Description copied from class:
Numeric
- Calculate x+k&this.
- Overrides:
addReversed
in class Quantity
toStringDate
public void toStringDate(java.lang.StringBuffer sbuf)
toStringTime
public void toStringTime(java.lang.StringBuffer sbuf)
isZoneUnspecified
public boolean isZoneUnspecified()
getZoneMinutes
public int getZoneMinutes()
minutesToTimeZone
public static java.util.TimeZone minutesToTimeZone(int minutes)
- Get a TimeZone object for a given offset.
- Parameters:
minutes
- timezone offset in minutes.
setTimeZone
public void setTimeZone(java.util.TimeZone timeZone)
toStringZone
public void toStringZone(java.lang.StringBuffer sbuf)
toStringZone
public static void toStringZone(int minutes,
java.lang.StringBuffer sbuf)
toString
public void toString(java.lang.StringBuffer sbuf)
toString
public java.lang.String toString()
- Overrides:
toString
in class Numeric
isExact
public boolean isExact()
- Specified by:
isExact
in class Numeric
isZero
public boolean isZero()
- Specified by:
isZero
in class Numeric
unit
public Unit unit()
- Overrides:
unit
in class Quantity
number
public Complex number()
- Specified by:
number
in class Quantity