uk.ac.starlink.hapi

## Class Times

- java.lang.Object
- - uk.ac.starlink.hapi.Times

-     public class Times
      extends java.lang.Object

  Utilities for manipulating time values. Unix seconds are seconds elapsed since 1970-01-01T00:00:00. ISO-8601 refers to the restricted profile used by HAPI.
  Since:
    24 Jan 2024

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.text.DateFormat` | `createDateFormat(java.lang.String pattern)` Creates a format for rendering dates.
    `static java.lang.String` | `formatUnixSeconds(long unixSec, java.text.DateFormat format)` Formats an epoch in Unix seconds using a supplied date format.
    `static java.lang.String` | `formatUnixSeconds(long unixSec, java.lang.String fmt)` Formats an epoch in Unix seconds using a supplied date pattern.
    `static double` | `isoToUnixSeconds(java.lang.String isoTime)` Decodes an ISO-8601 string to Unix seconds.
    `static int` | `secToYear(long sec)` Converts unix seconds to year since 0AD.
    `static long` | `yearToSec(int year)` Converts year since 0AD to unix seconds.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### isoToUnixSeconds

          public static double isoToUnixSeconds(java.lang.String isoTime)

      Decodes an ISO-8601 string to Unix seconds.
      Parameters:
        `isoTime` - epoch specified in ISO-8601
      Returns:
        epoch in Unix seconds, or NaN if isoTime can't be parsed

    - #### formatUnixSeconds

          public static java.lang.String formatUnixSeconds(long unixSec,
                                                           java.text.DateFormat format)

      Formats an epoch in Unix seconds using a supplied date format.
      Parameters:
        `unixSec` - time in unix seconds
        `format` - time format
      Returns:
        formatted date

    - #### formatUnixSeconds

          public static java.lang.String formatUnixSeconds(long unixSec,
                                                           java.lang.String fmt)

      Formats an epoch in Unix seconds using a supplied date pattern.
      Parameters:
        `unixSec` - time in unix seconds
        `fmt` - time format
      Returns:
        formatted date
      See Also:
        `SimpleDateFormat`

    - #### createDateFormat

          public static java.text.DateFormat createDateFormat(java.lang.String pattern)

      Creates a format for rendering dates.
      Parameters:
        `pattern` - format pattern
      Returns:
        format
      See Also:
        `SimpleDateFormat`

    - #### secToYear

          public static int secToYear(long sec)

      Converts unix seconds to year since 0AD.
      Parameters:
        `sec` - epoch in unix seconds
      Returns:
        year in which epoch occurs

    - #### yearToSec

          public static long yearToSec(int year)

      Converts year since 0AD to unix seconds.
      Parameters:
        `year` - year
      Returns:
        unix seconds