public final class Conversions
extends java.lang.Object
PropertyState
s
of different types. All conversions defined in this class are compatible with the conversions specified
in JSR-283 $3.6.4. However, some conversion in this class might not be defined in JSR-283.
Example:
double three = convert("3.0").toDouble();
Modifier and Type | Class and Description |
---|---|
static class |
Conversions.Converter
A converter converts a value to its representation as a specific target type.
|
Modifier and Type | Method and Description |
---|---|
static Conversions.Converter |
convert(java.math.BigDecimal value)
Create a converter for a decimal.
|
static Conversions.Converter |
convert(Blob value)
Create a converter for a binary.
|
static Conversions.Converter |
convert(boolean value)
Create a converter for a boolean.
|
static Conversions.Converter |
convert(double value)
Create a converter for a double.
|
static Conversions.Converter |
convert(long value)
Create a converter for a long.
|
static Conversions.Converter |
convert(java.lang.String value)
Create a converter for a string.
|
static Conversions.Converter |
convert(java.lang.String value,
Type<?> type)
Create a converter for a date.
|
public static Conversions.Converter convert(java.lang.String value)
value
- The string to convertvalue
java.lang.NumberFormatException
public static Conversions.Converter convert(Blob value)
String
the binary in interpreted as UTF-8 encoded string.value
- The binary to convertvalue
java.lang.IllegalArgumentException
- if the binary is inaccessiblepublic static Conversions.Converter convert(long value)
String.valueOf(long)
is used for the conversion to String
.
The conversions to double
and long
return the value
itself.
The conversion to decimal uses new BigDecimal.valueOf(long)
.
The conversion to date interprets the value as number of milliseconds since 1970-01-01T00:00:00.000Z
.value
- The long to convertvalue
public static Conversions.Converter convert(double value)
String.valueOf(double)
is used for the conversion to String
.
The conversions to double
and long
return the value
itself where in the former case
the value is casted to long
.
The conversion to decimal uses BigDecimal.valueOf(double)
.
The conversion to date interprets toLong()
as number of milliseconds since
1970-01-01T00:00:00.000Z
.value
- The double to convertvalue
public static Conversions.Converter convert(java.lang.String value, Type<?> type)
ISO8601.format(Calendar)
is used for the conversion to String
.
The conversions to double
, long
and BigDecimal
return the number of milliseconds
since 1970-01-01T00:00:00.000Z
.value
- The date to convertvalue
public static Conversions.Converter convert(boolean value)
Boolean.toString(boolean)
is used for the conversion to String
.value
- The boolean to convertvalue
public static Conversions.Converter convert(java.math.BigDecimal value)
BigDecimal.toString()
is used for the conversion to String
.
BigDecimal.longValue()
and BigDecimal.doubleValue()
is used for the conversions to
long
and double
, respectively.
The conversion to date interprets toLong()
as number of milliseconds since
1970-01-01T00:00:00.000Z
.value
- The decimal to convertvalue
Copyright © 2010 - 2020 Adobe. All Rights Reserved