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 intDATE_MASKstatic intDAY_MASKstatic TimeZoneGMTstatic intHOURS_MASKstatic intMINUTES_MASKstatic intMONTH_MASKstatic intSECONDS_MASKstatic intTIME_MASKstatic intTIMEZONE_MASKstatic intYEAR_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 DateTimeadd(DateTime x, Duration y, int k)Numericadd(Object y, int k)Return this + k * obj.static DateTimeaddMinutes(DateTime x, int y)NumericaddReversed(Numeric x, int k)Calculatex+k&this.static DateTimeaddSeconds(DateTime x, int y)DateTimeadjustTimezone(int newOffset)DateTimecast(int newComponents)static intcompare(DateTime date1, DateTime date2)Return -1, 0, or 1, depending on which value is greater.intcompare(Object obj)Return an integer for which ofthisorobjis larger.intcomponents()static intdaysInMonth(int month, int year)intgetDay()intgetHours()intgetMinutes()intgetMonth()intgetNanoSecondsOnly()intgetSecondsOnly()intgetWholeSeconds()intgetYear()intgetZoneMinutes()booleanisExact()static booleanisLeapYear(int year)booleanisZero()booleanisZoneUnspecified()static TimeZoneminutesToTimeZone(int minutes)Get a TimeZone object for a given offset.Complexnumber()static DateTimeparse(String value, int mask)voidsetTimeZone(TimeZone timeZone)static Durationsub(DateTime date1, DateTime date2)StringtoString()voidtoString(StringBuffer sbuf)voidtoStringDate(StringBuffer sbuf)voidtoStringTime(StringBuffer sbuf)static voidtoStringZone(int minutes, StringBuffer sbuf)voidtoStringZone(StringBuffer sbuf)Unitunit()DateTimewithZoneUnspecified()-
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:NumericReturn an integer for which ofthisorobjis larger. Return 1 ifthis>obj; 0 ifthis==obj; -1 ifthis<obj; -2 ifthis!=objotherwise (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:NumericReturn this + k * obj.
-
addReversed
public Numeric addReversed(Numeric x, int k)
Description copied from class:NumericCalculatex+k&this.- Overrides:
addReversedin 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)
-
-