public class Util extends Object
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static long |
currentTimeMillis()
Gets the application time in milliseconds.
|
static <T> T[] |
newArray(Class<T[]> type,
int length)
Allocates a new array of object references from the given array type and
length.
|
static long |
platformTimeMillis()
Gets an arbitrary time in milliseconds.
|
static long |
platformTimeNanos()
Gets an arbitrary time in nanoseconds.
|
static void |
setCurrentTimeMillis(Date d)
Sets the application time.
|
static void |
setCurrentTimeMillis(long t)
Sets the application time.
|
public static long currentTimeMillis()
The result of this method is the same as the
System.currentTimeMillis()
method one.
public static long platformTimeMillis()
Only elapsed time between two calls is meaningful.
public static long platformTimeNanos()
Only elapsed time between two calls is meaningful.
public static void setCurrentTimeMillis(long t)
This time does not change the platform time.
t
- the application time to set in millisecondsIllegalArgumentException
- if t
is negativepublic static void setCurrentTimeMillis(Date d)
This time does not change the platform time. The
Util.setCurrentTimeMillis(d)
method has the same effect as
Util.setCurrentTimeMillis(d.getTime())
.
d
- the application time to setpublic static <T> T[] newArray(Class<T[]> type, int length)
T
- the type of the array elementstype
- the type of the array to allocatelength
- the length of the array to allocateNullPointerException
- if the type is null
OutOfMemoryError
- if the array could not be allocated