Package uk.ac.starlink.table
Class TimeMapper
java.lang.Object
uk.ac.starlink.table.TimeMapper
- All Implemented Interfaces:
DomainMapper
DomainMapper for mapping values to epochs in a common time scale.
- Since:
- 12 Aug 2013
- Author:
- Mark Taylor
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TimeMapper
Mapper for numeric values in decimal year (since 0 AD).static final TimeMapper
Mapper for ISO-8601 strings.static final TimeMapper
Mapper for numeric values in Julian Day.static final TimeMapper
Mapper for numeric values in Modified Julian Date.static final TimeMapper
Mapper for numeric values (already) in unix seconds. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
TimeMapper
(Class<?> sourceClass, String sourceName, String sourceDescription) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionClass
<?> Returns the type of values from which this mapper instance can convert.Returns a description of the type of source values which this mapper can convert from.Returns a short name for the type of source values which this mapper can convert from.ReturnsTimeDomain.INSTANCE
.static TimeMapper[]
Returns a selection of time mapper instances.abstract double
toUnixSeconds
(Object sourceValue) Maps a source value to time in seconds since the Unix epoch (1970-01-01T00:00:00).
-
Field Details
-
DECIMAL_YEAR
Mapper for numeric values in decimal year (since 0 AD). -
MJD
Mapper for numeric values in Modified Julian Date. -
JD
Mapper for numeric values in Julian Day. -
UNIX_SECONDS
Mapper for numeric values (already) in unix seconds. -
ISO_8601
Mapper for ISO-8601 strings.
-
-
Constructor Details
-
TimeMapper
Constructor.- Parameters:
sourceClass
- source classsourceName
- source type namesourceDescription
- source type description
-
-
Method Details
-
getTargetDomain
ReturnsTimeDomain.INSTANCE
.- Specified by:
getTargetDomain
in interfaceDomainMapper
- Returns:
- domain identifier
-
getSourceClass
Description copied from interface:DomainMapper
Returns the type of values from which this mapper instance can convert. This should be as specific as possible to cover all the possible options, but in some cases that may mean it has simply to returnObject.class
.- Specified by:
getSourceClass
in interfaceDomainMapper
- Returns:
- class of mappable source objects to which this mapper can be applied
-
getSourceName
Description copied from interface:DomainMapper
Returns a short name for the type of source values which this mapper can convert from.- Specified by:
getSourceName
in interfaceDomainMapper
- Returns:
- mapper source type name
-
getSourceDescription
Description copied from interface:DomainMapper
Returns a description of the type of source values which this mapper can convert from.- Specified by:
getSourceDescription
in interfaceDomainMapper
- Returns:
- mapper source type description
-
toUnixSeconds
Maps a source value to time in seconds since the Unix epoch (1970-01-01T00:00:00). The time scale is generally assumed to be UTC, though conversions may not always be performed, for instance for values in which the intended time scale is not obvious.A java (IEEE 754) double has 52+1 bits of precision, which I make 52*ln(2)/ln(10)=15.65 decimal places, and a year contains 3.15e7 seconds, which gives you the following precisions:
- epoch +/- 1.7 months: 1 nanosecond precision
- epoch +/- 140 years: 1 microsecond precision
- epoch +/- 140 kyears: 1 millisecond precision
- epoch +/- 140 Myears: 1 second precision
- Parameters:
sourceValue
- value in source domain- Returns:
- number of seconds since midnight 1 Jan 1970
-
getTimeMappers
Returns a selection of time mapper instances.
-