Package gnu.math
Class DateTime
- java.lang.Object
-
- java.lang.Number
-
- gnu.math.Numeric
-
- gnu.math.Quantity
-
- gnu.math.DateTime
-
- All Implemented Interfaces:
Serializable
,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..- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description 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
TIME_MASK
static int
TIMEZONE_MASK
static int
YEAR_MASK
-
Constructor Summary
Constructors Constructor Description DateTime(int mask)
DateTime(int mask, GregorianCalendar calendar)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DateTime
add(DateTime x, Duration y, int k)
Numeric
add(Object y, int k)
Return this + k * obj.static DateTime
addMinutes(DateTime x, int y)
Numeric
addReversed(Numeric x, int k)
Calculatex+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(Object obj)
Return an integer for which ofthis
orobj
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 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)
static void
toStringZone(int minutes, StringBuffer sbuf)
void
toStringZone(StringBuffer sbuf)
Unit
unit()
DateTime
withZoneUnspecified()
-
Methods inherited from class gnu.math.Quantity
abs, add, compare, compareReversed, dimensions, div, divide, divReversed, doubleImagValue, doubleJmagValue, doubleKmagValue, doubleValue, im, imValue, jm, jmValue, km, kmValue, make, make, make, mul, mulReversed, neg, re, reValue, times, toString
-
Methods inherited from class gnu.math.Numeric
add, asNumericOrNull, div_inv, equals, floatValue, geq, grt, intValue, longValue, mul_ident, power, sub, toExact, toInexact
-
Methods inherited from class java.lang.Number
byteValue, shortValue
-
-
-
-
Field Detail
-
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 TimeZone GMT
-
-
Constructor Detail
-
DateTime
public DateTime(int mask)
-
DateTime
public DateTime(int mask, GregorianCalendar calendar)
-
-
Method Detail
-
components
public int components()
-
cast
public DateTime cast(int newComponents)
-
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(Object obj)
Description copied from class:Numeric
Return an integer for which ofthis
orobj
is larger. Return 1 ifthis>obj
; 0 ifthis==obj
; -1 ifthis<obj
; -2 ifthis!=obj
otherwise (for example if either is NaN); -3 if not comparable (incompatible types).
-
withZoneUnspecified
public DateTime withZoneUnspecified()
-
adjustTimezone
public DateTime adjustTimezone(int newOffset)
-
add
public Numeric add(Object y, int k)
Description copied from class:Numeric
Return this + k * obj.
-
addReversed
public Numeric addReversed(Numeric x, int k)
Description copied from class:Numeric
Calculatex+k&this
.- Overrides:
addReversed
in classQuantity
-
toStringDate
public void toStringDate(StringBuffer sbuf)
-
toStringTime
public void toStringTime(StringBuffer sbuf)
-
isZoneUnspecified
public boolean isZoneUnspecified()
-
getZoneMinutes
public int getZoneMinutes()
-
minutesToTimeZone
public static TimeZone minutesToTimeZone(int minutes)
Get a TimeZone object for a given offset.- Parameters:
minutes
- timezone offset in minutes.
-
setTimeZone
public void setTimeZone(TimeZone timeZone)
-
toStringZone
public void toStringZone(StringBuffer sbuf)
-
toStringZone
public static void toStringZone(int minutes, StringBuffer sbuf)
-
toString
public void toString(StringBuffer sbuf)
-
-