Package uk.ac.starlink.ttools.plot2.geom
Class TimeFormat
java.lang.Object
uk.ac.starlink.ttools.plot2.geom.TimeFormat
Formats numeric values to strings to provide axis ticks and
user-viewable coordinate readouts.
- Since:
- 12 Jul 2013
- Author:
- Mark Taylor
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TimeFormat
Time format for year decimal year.static final TimeFormat
Time format for ISO-8601 dates.static final TimeFormat
Time format for Modified Julian Date.static final TimeFormat
Time format for seconds since the Unix epoch. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic double
decimalYearToUnixSeconds
(double decYear) Converts decimal years to unix seconds.abstract String
formatTime
(double unixSec, double secPrecision) Formats a time value to a given precision.Returns a short description of this format.Returns the name of this format.static TimeFormat[]
Returns a list of all the known implementations of this class.abstract Ticker
Returns an object for generating ticks to label the time axis.abstract double
Turns a formatted time string into the equivalent value in unix seconds.toString()
static double
unixSecondsToDecimalYear
(double unixSec) Converts unix seconds to decimal year.
-
Field Details
-
ISO8601
Time format for ISO-8601 dates. -
DECIMAL_YEAR
Time format for year decimal year. -
MJD
Time format for Modified Julian Date. -
UNIX_SECONDS
Time format for seconds since the Unix epoch.
-
-
Constructor Details
-
TimeFormat
Constructor.- Parameters:
name
- format namedescription
- short description
-
-
Method Details
-
formatTime
Formats a time value to a given precision.- Parameters:
unixSec
- time value in unix secondssecPrecision
- precision of formatted string in seconds- Returns:
- formatted time value
-
parseTime
Turns a formatted time string into the equivalent value in unix seconds. This is the inverse offormatTime
.- Parameters:
timeStr
- formatted time value- Returns:
- time in unix seconds
- Throws:
NumberFormatException
- if timeStr cannot be parsed to a time in this format
-
getTicker
Returns an object for generating ticks to label the time axis.- Returns:
- tick calculator
-
getFormatName
Returns the name of this format.- Returns:
- format name
-
getFormatDescription
Returns a short description of this format.- Returns:
- format description
-
toString
-
getKnownFormats
Returns a list of all the known implementations of this class.- Returns:
- known time formats
-
unixSecondsToDecimalYear
public static double unixSecondsToDecimalYear(double unixSec) Converts unix seconds to decimal year.- Parameters:
unixSec
- seconds since the Unix epoch- Returns:
- years since 0 AD
-
decimalYearToUnixSeconds
public static double decimalYearToUnixSeconds(double decYear) Converts decimal years to unix seconds.- Parameters:
decYear
- years since 0 AD- Returns:
- seconds since the Unix epoch
-