|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD | |||||||||
java.lang.Objectjava.lang.Enum<TimeInterval>
com.antelmann.calendar.TimeInterval
public enum TimeInterval
provides different intervals for time ranges
TimeUnit,
Month,
WeekDay| Nested Class Summary | |
|---|---|
static class |
TimeInterval.Converter
|
| Nested classes/interfaces inherited from interface com.antelmann.util.Localizable |
|---|
Localizable.Adapter |
| Enum Constant Summary | |
|---|---|
DAY
|
|
HOUR
|
|
MILLISECOND
|
|
MINUTE
|
|
MONTH
defined as 30 days in regards to its milliseconds |
|
QUARTER
defined as 3 months (90 days) in regards to its milliseconds |
|
SECOND
|
|
WEEK
|
|
YEAR
defined as 4 quarters (360 days) in regards to its milliseconds |
|
| Method Summary | |
|---|---|
Date |
addInterval(Date date,
int amount)
|
Date |
addInterval(Date date,
int amount,
Calendar cal)
adds the date interval times the given amount to the given date |
long |
addInterval(long time,
int amount)
|
long |
addInterval(long time,
int amount,
Calendar cal)
|
Date |
adjust(Date date,
int n)
returns a date that is adjusted to the given amount by this interval. |
Date |
adjustToBegin(Date date)
|
Date |
adjustToBegin(Date date,
Calendar cal)
adjusts the date in a way that it always represents the begin time of the interval. |
long |
adjustToBegin(long time)
|
long |
adjustToBegin(long time,
Calendar cal)
|
Date |
adjustToEnd(Date date)
|
Date |
adjustToEnd(Date date,
Calendar cal)
|
long |
adjustToEnd(long time)
|
long |
adjustToEnd(long time,
Calendar cal)
|
long |
count(Date date0,
Date date1)
|
long |
count(long time0,
long time1)
|
static TimeInterval |
fromSymbol(String symbol)
|
static TimeInterval |
fromTimeUnit(TimeUnit unit)
may return null if the given unit has no corresponding interval |
static TimeInterval[] |
getDateIntervals()
returns all intervals greater or equal to DAY |
ArrayList<Date> |
getEntriesInRange(Date begin,
Date end)
|
ArrayList<Date> |
getEntriesInRange(Range<? extends Date> range)
provides an easy way to obtain a list of interval entries that enclose the given range, where every returned entry is timed at the beginning of the interval. |
DateFormat |
getFormat()
returns an appropriate format that maps to this interval |
Range<Date> |
getIntervalDateRange(Date date)
|
Locale |
getLocale()
allows access to the Locale that this instance currently uses to localize its messages, |
String |
getUnitName()
provides the fully spelled name for this unit |
String |
getUnitName(Locale l)
|
String |
getUnitSymbol()
provides a short symbolic representation of this unit |
boolean |
isInSameInterval(Date time1,
Date time2)
|
boolean |
isInSameInterval(long time1,
long time2)
|
long |
milliseconds()
|
long |
round(long time)
|
int |
seconds()
convenience method |
void |
setLocale(Locale locale,
Object context)
sets the Locale for this object so that all subsequent return values of method calls to this instance can be localized accordingly until a different Locale is set. |
BaseUnit |
toBaseUnit()
allows conversions with other custom time units |
double |
toDecimal(long millis)
|
String |
toString()
|
TimeUnit |
toTimeUnit()
may return null for intervals without a corresponding unit |
static TimeInterval |
valueOf(String name)
Returns the enum constant of this type with the specified name. |
static TimeInterval[] |
values()
Returns an array containing the constants of this enum type, in the order they are declared. |
| Methods inherited from class java.lang.Enum |
|---|
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf |
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Enum Constant Detail |
|---|
public static final TimeInterval MILLISECOND
public static final TimeInterval SECOND
public static final TimeInterval MINUTE
public static final TimeInterval HOUR
public static final TimeInterval DAY
public static final TimeInterval WEEK
public static final TimeInterval MONTH
public static final TimeInterval QUARTER
public static final TimeInterval YEAR
| Method Detail |
|---|
public static TimeInterval[] values()
for (TimeInterval c : TimeInterval.values()) System.out.println(c);
public static TimeInterval valueOf(String name)
name - the name of the enum constant to be returned.
IllegalArgumentException - if this enum type has no constant
with the specified name
NullPointerException - if the argument is nullpublic static TimeInterval[] getDateIntervals()
DAY
public static TimeInterval fromSymbol(String symbol)
public Locale getLocale()
Localizable
getLocale in interface LocalizableLocalizable.setLocale(Locale, Object)
public void setLocale(Locale locale,
Object context)
Localizable
setLocale in interface Localizablelocale - the Locale that is to be used to determine return values for all methods
of this instance; if set to null, the default locale is to be used.context - a context that may be required for this instance to load the resources for the given locale;
this context may be null for objects that do not require an external context.
Examples of a context may be a database, a resource file, some map or no context at all.Localizable.getLocale()public DateFormat getFormat()
public Range<Date> getIntervalDateRange(Date date)
public boolean isInSameInterval(Date time1,
Date time2)
public boolean isInSameInterval(long time1,
long time2)
public ArrayList<Date> getEntriesInRange(Date begin,
Date end)
throws IllegalArgumentException
IllegalArgumentExceptiongetEntriesInRange(Range)
public ArrayList<Date> getEntriesInRange(Range<? extends Date> range)
throws IllegalArgumentException
range - only closed and typed ranges are supported; the time of the dates are ignored
IllegalArgumentException - if the given range is not closed or not typedRange.isTyped(Class),
Range.isClosedRange()
public long count(long time0,
long time1)
public long count(Date date0,
Date date1)
public long round(long time)
public long adjustToEnd(long time)
public Date adjustToEnd(Date date)
public Date adjustToEnd(Date date,
Calendar cal)
public long adjustToEnd(long time,
Calendar cal)
public long adjustToBegin(long time)
public Date adjustToBegin(Date date)
public Date adjustToBegin(Date date,
Calendar cal)
public long adjustToBegin(long time,
Calendar cal)
public Date adjust(Date date,
int n)
MINUTE with n = 5 would return values that are
guaranteed to be 5 minutes apart for each given date.
This is useful when used with a PatternExtractor that is supposed
to produce values for 5 minute intervals, for instance
public Date addInterval(Date date,
int amount)
public long addInterval(long time,
int amount)
public Date addInterval(Date date,
int amount,
Calendar cal)
public long addInterval(long time,
int amount,
Calendar cal)
public String toString()
toString in class Enum<TimeInterval>@Localized public String getUnitName()
Unit
getUnitName in interface Unitpublic String getUnitName(Locale l)
@Todo(value="localize") public String getUnitSymbol()
Unit
getUnitSymbol in interface Unitpublic long milliseconds()
public double toDecimal(long millis)
public int seconds()
public BaseUnit toBaseUnit()
public TimeUnit toTimeUnit()
public static TimeInterval fromTimeUnit(TimeUnit unit)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD | |||||||||