T - Actual instant type.public abstract class STAbstractInstant<T extends STAbstractInstant<T>> extends Object implements Comparable<T>, Serializable
| Modifier and Type | Field and Description |
|---|---|
protected Date |
dateTime
A
Date object used inside this instant. |
static String |
FORMAT_PATTERN_DATE_ISO
Date format ISO pattern.
|
static String |
FORMAT_PATTERN_DATETIME_ISO
Date/time format ISO pattern.
|
static String |
FORMAT_PATTERN_TIME_ISO
Time format ISO pattern.
|
| Constructor and Description |
|---|
STAbstractInstant() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract T |
clone()
TODO : REMOVE, cf http://www.javapractices.com/topic/TopicAction.do?Id=71
|
int |
compareTo(T o)
Compares 2 instant objects.
|
protected Calendar |
createCalendar()
Creates a new
GregorianCalendar instance and set current date time (dateTime) to this calendar. |
boolean |
equals(Object obj) |
int |
hashCode() |
boolean |
isAfter(T o)
Checks if current instant is after given instant.
|
boolean |
isAfterOrEqual(T o)
Checks if current instant is after given instant.
|
boolean |
isBefore(T o)
Checks if current instant is before given instant.
|
boolean |
isBeforeOrEqual(T o)
Checks if current instant is before or equal given instant.
|
boolean |
isBetween(T start,
T end)
Checks if current instant is between 2 given instants.
|
abstract boolean |
isSet()
Checks if current instant is set.
|
static boolean |
isSet(STAbstractInstant<?> instant)
Checks if a given instant is set.
|
protected T |
rawAdd(int field,
int value)
Safely adds a value into a given field in source calendar.
|
protected T |
rawSubstract(int field,
int value)
Safely substracts a value from a given field in source calendar.
|
protected void |
reset()
Resets all fields of this instant.
|
protected void |
setDateFields(int year,
int month,
int dayOfMonth)
Sets all date fields.
|
protected void |
setTimeFields(int hour,
int minute,
int second)
Sets all time fields.
|
String |
toIsoDateTimeString() |
String |
toString()
Returns string presentation of this instant in ISO date/time format with default locale (See
Locale.getDefault()). |
String |
toString(String pattern)
Returns string presentation of this instant in given format pattern with default locale (See
Locale.getDefault()). |
String |
toString(String pattern,
Locale locale)
Returns string presentation of this instant in given format pattern with given locale instance.
|
public static final String FORMAT_PATTERN_DATE_ISO
public static final String FORMAT_PATTERN_TIME_ISO
public static final String FORMAT_PATTERN_DATETIME_ISO
public static boolean isSet(STAbstractInstant<?> instant)
instant - Instant to be checked. null is considered unset.true if given instant is set.public abstract boolean isSet()
true if this instant is set.public String toString(String pattern, Locale locale)
pattern - Pattern to format instant value. If no pattern is specified (that is, null or empty
string), ISO date/time format pattern will be used.locale - Locale that provides language setting for result presentation. If no locale is specified, the default
locale will be used (See Locale.getDefault()).Locale.getDefault()public String toString()
Locale.getDefault()).public String toString(String pattern)
Locale.getDefault()).pattern - Pattern to format instant value. If no pattern is specified (that is, null or empty
string), ISO date/time format pattern will be used.public String toIsoDateTimeString()
public int compareTo(T o)
Remarks: null values are always before not-null values. And unset instants are compared using
the same method that has been applied to null.
compareTo in interface Comparable<T extends STAbstractInstant<T>>o - An instant object comparing with this object.null, are unset, or have the same.
null, is unset while this instant is set, or before this
instant.
public boolean isBefore(T o)
o - Given instant.true if current instant is before given instant. Otherwise, return false.public boolean isBeforeOrEqual(T o)
o - Given instant.true if current instant is before or equal given instant. Otherwise, return
false.public boolean isAfter(T o)
o - Given instant.true if current instant is after given instant. Otherwise, return false.public boolean isAfterOrEqual(T o)
o - Given instant.true if current instant is after or equal given instant. Otherwise, return
false.public boolean isBetween(T start, T end)
start - Lower bound instant. Required.end - Upper bound instant. Required.true if current instant is finity and in [start, end].protected void reset()
protected abstract T clone()
protected Calendar createCalendar()
GregorianCalendar instance and set current date time (dateTime) to this calendar.protected T rawAdd(int field, int value)
field - Calendar field. See Calendar documentation for a list of valid fields.value - Adding value. Only positive number or zero is allowed.ArithmeticException - if given value is negative.protected T rawSubstract(int field, int value)
field - Calendar field. See Calendar documentation for a list of valid fields.value - Substracting value. Only positive number or zero is allowed.ArithmeticException - if given value is negative.protected void setDateFields(int year,
int month,
int dayOfMonth)
year - Year value, 4-digit number.month - Month value, from 1 to 12.dayOfMonth - Day of month, from 1 to maximum 31.protected void setTimeFields(int hour,
int minute,
int second)
hour - Hour of day (0 to 23).minute - Minute of hour (0 to 59).second - Second of minute (0 to 59).millisec - Millisecond (0 to 999).Copyright © 2021. All rights reserved.