|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object prefuse.util.TimeLib
public class TimeLib
Library routines for dealing with times and time spans. All time values
are given as long values, indicating the number of milliseconds since
the epoch (January 1, 1970). This is the same time format returned
by the System.currentTimeMillis()
method.
Field Summary | |
---|---|
static int |
CENTURY
Represents a century, 100 years |
static int |
DECADE
Represents a decade, 10 years |
static int |
MILLENIUM
Represents a millenium, 1000 years. |
Method Summary | |
---|---|
static java.util.Calendar |
clearTo(java.util.Calendar c,
int field)
Clear the given calendar, setting to zero all time values less than or equal to that of the given field. |
static int |
get(java.util.Calendar c,
int field)
Get the value of the given time field for a Calendar. |
static long |
getClearedTime(long t,
java.util.Calendar c,
int field)
Get the timestamp resulting from clearing (setting to zero) all time values less than or equal to that of the given field. |
static long |
getDate(java.util.Calendar c,
int year,
int month,
int day)
Get the timestamp for the given year, month, and, day. |
static java.util.Date |
getDate(java.lang.Class type,
long d)
Get a new Date instance of the specified subclass and given long value. |
static long |
getTime(java.util.Calendar c,
int hour,
int minute,
int second)
Get a timestamp for the given hour, minute, and second. |
static int |
getUnitsBetween(long t0,
long t1,
int field)
Get the number of time units between the two given timestamps. |
static void |
increment(java.util.Calendar c,
int field,
int val)
Increment a calendar by a given number of time units. |
static boolean |
isMultiYear(int field)
Indicates if a field value indicates a timespan greater than one year. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MILLENIUM
public static final int CENTURY
public static final int DECADE
Method Detail |
---|
public static int getUnitsBetween(long t0, long t1, int field)
t0
- the first timestamp (as a long)t1
- the second timestamp (as a long)field
- the time unit to use, one of the Calendar
fields, or one of the extended fields provided by this class
(MILLENIUM, CENTURY, or DECADE).
public static void increment(java.util.Calendar c, int field, int val)
c
- the calendar to incrementfield
- the time unit to increment, one of the
Calendar
fields, or one of the extended fields
provided by this class (MILLENIUM, CENTURY, or DECADE).val
- the number of time units to increment bypublic static int get(java.util.Calendar c, int field)
Calendar.get(int)
method, but include support for
the extended fields provided by this class (MILLENIUM, CENTURY, or
DECADE).
c
- the Calendarfield
- the time field
public static long getDate(java.util.Calendar c, int year, int month, int day)
c
- a Calendar to use to help compute the result. The state of the
Calendar will be overwritten.year
- the year to look upmonth
- the month to look up (months start at 0==January)day
- the day to look up
public static long getTime(java.util.Calendar c, int hour, int minute, int second)
c
- a Calendar to use to help compute the result. The state of the
Calendar will be overwritten.hour
- the hour, on a 24 hour clockminute
- the minute valuesecond
- the seconds value
public static java.util.Date getDate(java.lang.Class type, long d)
type
- the concrete subclass of the Date instance, must be an
instance of subclass of java.util.Dated
- the date/time value as a long
public static long getClearedTime(long t, java.util.Calendar c, int field)
Calendar.HOUR
will floor the time to nearest
hour which occurred before or at the given time (e.g., 1:32
--> 1:30).
t
- the reference timec
- a Calendar instance used to help compute the value, the
state of the Calendar will be overwritten.field
- the time field to clear to, one of the
Calendar
fields, or one of the extended fields
provided by this class (MILLENIUM, CENTURY, or DECADE).
public static java.util.Calendar clearTo(java.util.Calendar c, int field)
Calendar.HOUR
will floor the time to nearest
hour which occurred before or at the given time (e.g., 1:32
--> 1:30).
c
- the Calendar to clearfield
- the time field to clear to, one of the
Calendar
fields, or one of the extended fields
provided by this class (MILLENIUM, CENTURY, or DECADE).
public static boolean isMultiYear(int field)
field
- the time field
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |