public final class TimeStandardConverter extends Object
JulianDate
between different time standards.Modifier and Type | Method and Description |
---|---|
static JulianDate |
convert(JulianDate value,
TimeStandard to)
Converts the specified
JulianDate to the specified
TimeStandard . |
static int |
getConversionDistance(TimeStandard from,
TimeStandard to)
Gets the number of intermediate conversions that must be done to convert from
from to to . |
static boolean |
isConversionDefined(TimeStandard from,
TimeStandard to)
Determines if a conversion between two
TimeStandards has been defined. |
static void |
registerConversion(TimeStandard from,
TimeStandard to,
FormatConversionCallback<JulianDate,TimeStandard> conversion)
Registers a new conversion between time standards.
|
static boolean |
tryConvert(JulianDate value,
TimeStandard to,
JulianDate[] result)
Tries to convert the specified
JulianDate to the specified
TimeStandard , returning success or failure. |
public static boolean tryConvert(@Nonnull JulianDate value, @Nonnull TimeStandard to, @Nonnull JulianDate[] result)
JulianDate
to the specified
TimeStandard
, returning success or failure.value
- The JulianDate
to convert.to
- The TimeStandard
to convert value
to.result
- On input, an array with one element. On return, the array is populated with
the resulting JulianDate
equivalent to
value
in the new TimeStandard
.true
if value
could be converted to the
requested TimeStandard
to
; otherwise false
.@Nonnull public static JulianDate convert(@Nonnull JulianDate value, @Nonnull TimeStandard to)
JulianDate
to the specified
TimeStandard
.value
- The JulianDate
to convert.to
- The TimeStandard
to convert value
to.JulianDate
equivalent to value
in the new
TimeStandard
.public static int getConversionDistance(@Nonnull TimeStandard from, @Nonnull TimeStandard to)
from
to to
. For example, if a conversion
function is defined to directly convert between the time standards, 1 will be returned.
If the two standards are identical, 0 will be returned. If no conversion exists
at all, Integer.MAX_VALUE
will be returned.from
- The source time standard.to
- The destination time standard.public static void registerConversion(@Nonnull TimeStandard from, @Nonnull TimeStandard to, @Nonnull FormatConversionCallback<JulianDate,TimeStandard> conversion)
from
- The time standard that the conversion method converts from.to
- The time standard that the conversion method converts to.conversion
- The conversion method.public static boolean isConversionDefined(@Nonnull TimeStandard from, @Nonnull TimeStandard to)
TimeStandards
has been defined.from
- The source time standard.to
- The destination time standard.true
if a conversion is defined; otherwise false
.