| Method from org.jfree.data.time.RegularTimePeriod Detail: |
public static RegularTimePeriod createInstance(Class c,
Date millisecond,
TimeZone zone) {
RegularTimePeriod result = null;
try {
Constructor constructor = c.getDeclaredConstructor(
new Class[] {Date.class, TimeZone.class});
result = (RegularTimePeriod) constructor.newInstance(
new Object[] {millisecond, zone});
}
catch (Exception e) {
// do nothing, so null is returned
}
return result;
}
Creates a time period that includes the specified millisecond, assuming
the given time zone. |
public static Class downsize(Class c) {
if (c.equals(Year.class)) {
return Quarter.class;
}
else if (c.equals(Quarter.class)) {
return Month.class;
}
else if (c.equals(Month.class)) {
return Day.class;
}
else if (c.equals(Day.class)) {
return Hour.class;
}
else if (c.equals(Hour.class)) {
return Minute.class;
}
else if (c.equals(Minute.class)) {
return Second.class;
}
else if (c.equals(Second.class)) {
return Millisecond.class;
}
else {
return Millisecond.class;
}
}
|
public Date getEnd() {
return new Date(getLastMillisecond());
}
Returns the date/time that marks the end of the time period. This
method returns a new Date instance every time it is called. |
abstract public long getFirstMillisecond()
Returns the first millisecond of the time period. This will be
determined relative to the time zone specified in the constructor, or
in the calendar instance passed in the most recent call to the
#peg(Calendar) method. |
public long getFirstMillisecond(TimeZone zone) {
Calendar calendar = Calendar.getInstance(zone);
return getFirstMillisecond(calendar);
} Deprecated! As - of 1.0.3, you should avoid using this method (it creates
a new Calendar instance every time it is called). You are advised
to call #getFirstMillisecond(Calendar) instead.
Returns the first millisecond of the time period, evaluated within a
specific time zone. |
abstract public long getFirstMillisecond(Calendar calendar)
Returns the first millisecond of the time period, evaluated using the
supplied calendar (which incorporates a timezone). |
abstract public long getLastMillisecond()
Returns the last millisecond of the time period. This will be
determined relative to the time zone specified in the constructor, or
in the calendar instance passed in the most recent call to the
#peg(Calendar) method. |
public long getLastMillisecond(TimeZone zone) {
Calendar calendar = Calendar.getInstance(zone);
return getLastMillisecond(calendar);
} Deprecated! As - of 1.0.3, you should avoid using this method (it creates
a new Calendar instance every time it is called). You are advised
to call #getLastMillisecond(Calendar) instead.
Returns the last millisecond of the time period, evaluated within a
specific time zone. |
abstract public long getLastMillisecond(Calendar calendar)
Returns the last millisecond of the time period, evaluated using the
supplied calendar (which incorporates a timezone). |
public long getMiddleMillisecond() {
long m1 = getFirstMillisecond();
long m2 = getLastMillisecond();
return m1 + (m2 - m1) / 2;
}
Returns the millisecond closest to the middle of the time period. |
public long getMiddleMillisecond(TimeZone zone) {
Calendar calendar = Calendar.getInstance(zone);
long m1 = getFirstMillisecond(calendar);
long m2 = getLastMillisecond(calendar);
return m1 + (m2 - m1) / 2;
} Deprecated! As - of 1.0.3, you should avoid using this method (it creates
a new Calendar instance every time it is called). You are advised
to call #getMiddleMillisecond(Calendar) instead.
Returns the millisecond closest to the middle of the time period,
evaluated within a specific time zone. |
public long getMiddleMillisecond(Calendar calendar) {
long m1 = getFirstMillisecond(calendar);
long m2 = getLastMillisecond(calendar);
return m1 + (m2 - m1) / 2;
}
Returns the millisecond closest to the middle of the time period,
evaluated using the supplied calendar (which incorporates a timezone). |
abstract public long getSerialIndex()
Returns a serial index number for the time unit. |
public Date getStart() {
return new Date(getFirstMillisecond());
}
Returns the date/time that marks the start of the time period. This
method returns a new Date instance every time it is called. |
abstract public RegularTimePeriod next()
Returns the time period following this one, or null if some
limit has been reached. |
abstract public void peg(Calendar calendar)
Recalculates the start date/time and end date/time for this time period
relative to the supplied calendar (which incorporates a time zone). |
abstract public RegularTimePeriod previous()
Returns the time period preceding this one, or null if some
lower limit has been reached. |
public String toString() {
return String.valueOf(getStart());
}
Returns a string representation of the time period. |