gnu.math

Class DateTime

Implemented Interfaces:
Cloneable

public class DateTime
extends Quantity
implements 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..

Field Summary

static int
DATE_MASK
static int
DAY_MASK
static TimeZone
GMT
static int
HOURS_MASK
static int
MINUTES_MASK
static int
MONTH_MASK
static int
SECONDS_MASK
static int
TIMEZONE_MASK
static int
TIME_MASK
static int
YEAR_MASK

Fields inherited from class gnu.math.Numeric

CEILING, FLOOR, ROUND, TRUNCATE

Constructor Summary

DateTime(int mask)
DateTime(int mask, GregorianCalendar calendar)

Method Summary

Numeric
add(Object y, int k)
Return this + k * obj.
static DateTime
add(DateTime x, Duration y, int k)
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)
int
compare(Object obj)
Return an integer for which of {# code this} or {#code obj} is larger.
static int
compare(DateTime date1, DateTime date2)
Return -1, 0, or 1, depending on which value is greater.
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 TimeZone
minutesToTimeZone(int minutes)
Get a TimeZone object for a given offset.
Complex
number()
static DateTime
parse(String value, int mask)
void
setTimeZone(TimeZone timeZone)
static Duration
sub(DateTime date1, DateTime date2)
String
toString()
void
toString(StringBuffer sbuf)
void
toStringDate(StringBuffer sbuf)
void
toStringTime(StringBuffer sbuf)
void
toStringZone(StringBuffer sbuf)
static void
toStringZone(int minutes, StringBuffer sbuf)
Unit
unit()
DateTime
withZoneUnspecified()

Methods inherited from class gnu.math.Quantity

abs, add, add, addReversed, compare, compare, compareReversed, dimensions, div, divReversed, divide, doubleImagValue, doubleValue, im, imValue, make, make, make, mul, mulReversed, neg, number, re, reValue, times, toString, unit

Methods inherited from class gnu.math.Numeric

abs, add, add, addReversed, compare, compareReversed, div, divReversed, div_inv, equals, floatValue, geq, grt, intValue, isExact, isZero, longValue, mul, mulReversed, mul_ident, neg, power, sub, toString, toString

Field Details

DATE_MASK

public static final int DATE_MASK
Field Value:
14

DAY_MASK

public static final int DAY_MASK
Field Value:
8

GMT

public static TimeZone GMT

HOURS_MASK

public static final int HOURS_MASK
Field Value:
16

MINUTES_MASK

public static final int MINUTES_MASK
Field Value:
32

MONTH_MASK

public static final int MONTH_MASK
Field Value:
4

SECONDS_MASK

public static final int SECONDS_MASK
Field Value:
64

TIMEZONE_MASK

public static final int TIMEZONE_MASK
Field Value:
128

TIME_MASK

public static final int TIME_MASK
Field Value:
112

YEAR_MASK

public static final int YEAR_MASK
Field Value:
2

Constructor Details

DateTime

public DateTime(int mask)

DateTime

public DateTime(int mask,
                GregorianCalendar calendar)

Method Details

add

public Numeric add(Object y,
                   int k)
Return this + k * obj.
Overrides:
add in interface Quantity

add

public static DateTime add(DateTime x,
                           Duration y,
                           int k)

addMinutes

public static DateTime addMinutes(DateTime x,
                                  int y)

addReversed

public Numeric addReversed(Numeric x,
                           int k)
Calculate x+k&this.
Overrides:
addReversed in interface Quantity

addSeconds

public static DateTime addSeconds(DateTime x,
                                  int y)

adjustTimezone

public DateTime adjustTimezone(int newOffset)

cast

public DateTime cast(int newComponents)

compare

public int compare(Object obj)
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; -2 if this!=obj otherwise (for example if either is NaN); -3 if not comparable (incompatible types).
Overrides:
compare in interface Quantity

compare

public static int compare(DateTime date1,
                          DateTime date2)
Return -1, 0, or 1, depending on which value is greater.

components

public int components()

daysInMonth

public static int daysInMonth(int month,
                              int year)

getDay

public int getDay()

getHours

public int getHours()

getMinutes

public int getMinutes()

getMonth

public int getMonth()

getNanoSecondsOnly

public int getNanoSecondsOnly()

getSecondsOnly

public int getSecondsOnly()

getWholeSeconds

public int getWholeSeconds()

getYear

public int getYear()

getZoneMinutes

public int getZoneMinutes()


isLeapYear

public static boolean isLeapYear(int year)


isZoneUnspecified

public boolean isZoneUnspecified()

minutesToTimeZone

public static TimeZone minutesToTimeZone(int minutes)
Get a TimeZone object for a given offset.
Parameters:
minutes - timezone offset in minutes.

number

public Complex number()
Overrides:
number in interface Quantity

parse

public static DateTime parse(String value,
                             int mask)

setTimeZone

public void setTimeZone(TimeZone timeZone)



toString

public void toString(StringBuffer sbuf)

toStringDate

public void toStringDate(StringBuffer sbuf)

toStringTime

public void toStringTime(StringBuffer sbuf)

toStringZone

public void toStringZone(StringBuffer sbuf)

toStringZone

public static void toStringZone(int minutes,
                                StringBuffer sbuf)

unit

public Unit unit()
Overrides:
unit in interface Quantity