uk.ac.starlink.table
Class TimeDomain

java.lang.Object
  extended by uk.ac.starlink.table.TimeDomain
All Implemented Interfaces:
ValueDomain

public abstract class TimeDomain
extends Object
implements ValueDomain

Domain representing epoch values in a common time scale. The uniform conversion target for time values is doubles giving the number of 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:

It should be OK for most purposes.

Since:
12 Aug 2013
Author:
Mark Taylor

Field Summary
static TimeDomain DECIMAL_YEAR
          Domain for numeric values in decimal year (since 0 AD).
static TimeDomain ISO_8601
          Domain for ISO-8601 strings.
static TimeDomain MJD
          Domain for numeric values in Modified Julian Date.
static TimeDomain UNIX_SECONDS
          Domain for numeric values (already) in unix seconds.
 
Constructor Summary
protected TimeDomain(String name, String description)
          Constructor.
 
Method Summary
 String getDescription()
           
 String getName()
           
static TimeDomain[] getNumericTimeDomains()
          Returns a selection of time domain instances suitable for use with numeric input values.
abstract  double toUnixSeconds(Object value)
          Returns the time since the Unix epoch represented by a value in this domain.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uk.ac.starlink.table.ValueDomain
getValueClass
 

Field Detail

DECIMAL_YEAR

public static final TimeDomain DECIMAL_YEAR
Domain for numeric values in decimal year (since 0 AD).


MJD

public static final TimeDomain MJD
Domain for numeric values in Modified Julian Date.


UNIX_SECONDS

public static final TimeDomain UNIX_SECONDS
Domain for numeric values (already) in unix seconds.


ISO_8601

public static final TimeDomain ISO_8601
Domain for ISO-8601 strings.

Constructor Detail

TimeDomain

protected TimeDomain(String name,
                     String description)
Constructor.

Parameters:
name - domain name
description - domain descriptino
Method Detail

getName

public String getName()
Specified by:
getName in interface ValueDomain

getDescription

public String getDescription()
Specified by:
getDescription in interface ValueDomain

toUnixSeconds

public abstract double toUnixSeconds(Object value)
Returns the time since the Unix epoch represented by a value in this domain.

Parameters:
value - object value
Returns:
number of seconds since midnight 1 Jan 1970

getNumericTimeDomains

public static TimeDomain[] getNumericTimeDomains()
Returns a selection of time domain instances suitable for use with numeric input values.



Copyright © 2013 Central Laboratory of the Research Councils. All Rights Reserved.