Java Reference
In-Depth Information
method has a
String
parameter that names the property to retrieve.
Some forms have a second parameter (shown as
def
later) that is the
default value to return if no property is found with that name. Methods
that lack a default value parameter return an object that contains the
default value for the type. All these methods decode values in the stand-
ard formats for constants of the primitive type:
public static boolean
Boolean.getBoolean(String name)
public static Integer
Integer.getInteger(String name)
public static Integer
Integer.getInteger(String name, Integer def)
public static Integer
Integer.getInteger(String name, int
def)
public static Long
Long.getLong(String name)
public static Long
Long.getLong(String name, Long def)
public static Long
Long.getLong(String name, long def)
The
getBoolean
method is different from the othersit returns a
boolean
value instead of an object of class
Boolean
. If the property isn't present,
getBoolean
returns
false
; the other methods return
null
.
The classes
Character
,
Byte
,
Short
,
Float
, and
Double
do not have property
fetching methods. You can get the value as a string and use the mech-
anisms described in "
String Conversions
" on page
316
to convert to the
appropriate primitive type.
23.1.3. Utility Methods
The
System
class also contains a number of utility methods:
public static long
currentTimeMillis()
Returns the current time in milliseconds since the epoch
(00:00:00
GMT
, January 1, 1970). The time is returned in a