public final class DateOps
extends java.lang.Object
The following is the mapping of Progress language features to the corresponding feature in this class:
add-interval functionaddInterval(T, long, java.lang.String)
interval functioninterval(com.goldencode.p2j.util.date, com.goldencode.p2j.util.date, java.lang.String)
The above methods all return an instance of wrapper classes which allow the Progress unknown value to be properly handled. Overloaded versions of the methods exist which handle different combinations of primative type parameters, allowing the resulting code to be implemented without unnecessary construction of the wrapper types for all parameters.
Constructor and Description |
---|
DateOps() |
Modifier and Type | Method and Description |
---|---|
static <T extends date> |
addInterval(T dat,
long amount,
character unit)
Adds or subtracts a time amount to/from an instance of a date class
and returns the new date instance.
|
static <T extends date> |
addInterval(T dat,
long amount,
java.lang.String unit)
Adds or subtracts a time amount to/from an instance of a date class
and returns the new date instance.
|
static <T extends date> |
addInterval(T dat,
NumberType amount,
character unit)
Adds or subtracts a time amount to/from an instance of a date class
and returns the new date instance.
|
static <T extends date> |
addInterval(T dat,
NumberType amount,
java.lang.String unit)
Adds or subtracts a time amount to/from an instance of a date class
and returns the new date instance.
|
static int |
compare(date d1,
date d2)
Compares two date-related values.
|
private static int |
getGregorianField(java.lang.String pUnit)
Maps Progress calendar fields to Java Calendar fields.
|
private static long |
getIntervalInMillis(long amount,
java.lang.String unit)
Computes and returns an interval of a fixed size time unit.
|
static int64 |
interval(date d1,
date d2,
character unit)
Calculate the time interval between two date values and return it
in user-specified units.
|
static int64 |
interval(date d1,
date d2,
java.lang.String unit)
Calculate the time interval between two date values and return it
in user-specified units.
|
public static <T extends date> T addInterval(T dat, long amount, java.lang.String unit)
date
(or any subclass) and the same type will be returned.dat
- The date to add to or subtract from.amount
- If positive, the amount to add. If negative, the amount to subtract.unit
- One of the following time units: 'years', 'months', 'weeks', 'days', 'hours',
'minutes', 'seconds' or 'milliseconds'. Any case is accepted and it may be
specified as singular.unknown
if any input is unknown.public static <T extends date> T addInterval(T dat, NumberType amount, java.lang.String unit)
date
(or any subclass) and the same type will be returned.dat
- The date to add to or subtract from.amount
- If positive, the amount to add. If negative, the amount to
subtract.unit
- One of the following time units: 'years', 'months', 'weeks',
'days', 'hours', 'minutes', 'seconds' or 'milliseconds'. Any
case is accepted and it may be specified as singular.unknown
if any input is
unknown.public static <T extends date> T addInterval(T dat, long amount, character unit)
date
(or any subclass) and the same type will be returned.dat
- The date to add to or subtract from.amount
- If positive, the amount to add. If negative, the amount to
subtract.unit
- One of the following time units: 'years', 'months', 'weeks',
'days', 'hours', 'minutes', 'seconds' or 'milliseconds'. Any
case is accepted and it may be specified as singular.unknown
if any input is
unknown.public static <T extends date> T addInterval(T dat, NumberType amount, character unit)
date
(or any subclass) and the same type will be returned.dat
- The date to add to or subtract from.amount
- If positive, the amount to add. If negative, the amount to
subtract.unit
- One of the following time units: 'years', 'months', 'weeks',
'days', 'hours', 'minutes', 'seconds' or 'milliseconds'. Any
case is accepted and it may be specified as singular.unknown
if any input is
unknown.public static int64 interval(date d1, date d2, java.lang.String unit)
d1
- The first date value.d2
- The second date value.unit
- One of the following time units: 'years', 'months', 'weeks',
'days', 'hours', 'minutes', 'seconds' or 'milliseconds'. Any
case is accepted and it may be specified as singular.unknown
if any input is unknown.public static int64 interval(date d1, date d2, character unit)
d1
- The first date value.d2
- The second date value.unit
- One of the following time units: 'years', 'months', 'weeks',
'days', 'hours', 'minutes', 'seconds' or 'milliseconds'. Any
case is accepted and it may be specified as singular.unknown
if any input is
unknown.private static long getIntervalInMillis(long amount, java.lang.String unit)
amount
- The amount of units.unit
- One of the following time units: 'weeks', 'days', 'hours', 'minutes', 'seconds'
or 'milliseconds'. Any case is accepted and it may be specified as singular.private static int getGregorianField(java.lang.String pUnit)
pUnit
- The name of time unit from Progress.public static int compare(date d1, date d2)
d1
- The first date to compare.d2
- The second date to compare.