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 boolean |
isInInitialization()
Indicates whether the current code is part of the initialization phase.
|
static boolean |
isInMission()
Indicates whether the system has entered the mission phase, i.e.
|
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 boolean isInInitialization()
When Class.forName(String)
triggers classes to be loaded at
runtime dynamically, class initializations are done in a context where
isInInitialization()
is true
and isInMission()
is
true
.
true
if the initialization is ongoingImmortals
public static boolean isInMission()
true
if the initialization is doneImmortals
public 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 allocatedpublic 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(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 void setCurrentTimeMillis(long t)
This time does not change the platform time.
t
- the application time to set in millisecondsIllegalArgumentException
- if t
is negative