Class Time

java.lang.Object
gov.nasa.jpl.time.Time
All Implemented Interfaces:
ConvertableFromString, Comparable<Time>
Direct Known Subclasses:
EpochRelativeTime

public class Time extends Object implements Comparable<Time>, ConvertableFromString
This class is a SPICE-backed object-oriented way to represent Time in Java. It is intended to be imported and used/passed around as the sole way your program represents time, except for exporting to other files or programs. It represents time as TAI 10-nanosecond tics, so calculations should generally be accurate to well within a microsecond (though some SPICE calls have inherent uncertainty greater than that). It is backed by not a floating point number so it is suitable to discrete event simulators where there can be no ambiguity as to the ordering of times, and to allow comparison, addition, and multiplication without having to make SPICE calls (they are only made for creating times and exporting formats).
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final Pattern
     
    static final String
     
    static final Pattern
     
    static final Time
     
    static final Pattern
     
    static final String
     
    static final Pattern
     
    static final String
     
    protected long
     
    static final Pattern
     
    static final String
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    This is the empty time constructor, which will use 0 tics for the time input.
    protected
    Time(long tics)
    This protected constructor is used by the fromX and valueOf methods to actually assign the backing data.
     
    Time(Time t2)
    Copy constructor, also used for EpochRelativeTime
     
    The main Time constructor, that wraps str2et in SPICE if it is enabled, or a Java DateTime if it is not.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a Duration that is the absolute difference between the calling object and the parameter
    Adding a time and duration returns a time
    ceil(Duration resolution)
    Rounds the time up to the input resolution, based on the reference time.
    ceil(Duration resolution, Time referenceTime)
    Rounds the time up to the input resolution, based on the reference time.
    int
     
    static Time
    Return the current system time as a Time object.
    static Duration
    Wraps downleg(t, sc_id, body_id), but always passes body_id = EARTH_NAIF_ID (Earth) Uses default spacecraft id.
    static Duration
    downleg(Time t, int sc_id)
    Wraps downleg(t, sc_id, body_id), but always passes body_id = EARTH_NAIF_ID (Earth)
    static Duration
    downleg(Time t, int sc_id, int body_id)
    Wraps downleg(t, sc_id, body_id, time_reference) but always passes in "SCET" as time reference
    boolean
     
    boolean
    equalToWithin(Time t2, Duration resolution)
    Compares the time to another time object and returns true if t2 is within an input resolution of t1.
    static Time
    Returns the input earth receive time - the downleg time from the spacecraft - the upleg time to the spacecraft when the signal was sent.
    static Time
    ERT2ETT(Time ERT, int sc_id)
    Returns the input earth receive time - the downleg time from the spacecraft - the upleg time to the spacecraft when the signal was sent.
    static Time
    Returns the input spacecraft event time - upleg time to the spacecraft.
    static Time
    ERT2SCET(Time ERT, int sc_id)
    Returns the input spacecraft event time - upleg time to the spacecraft.
    static Time
    Returns the input earth transmit time + the upleg time to the spacecraft + the downleg time from the spacecraft when the signal arrives at the spacecraft.
    static Time
    ETT2ERT(Time ETT, int sc_id)
    Returns the input earth transmit time + the upleg time to the spacecraft + the downleg time from the spacecraft when the signal arrives at the spacecraft.
    static Time
    Returns the input earth transmit time + the upleg time to the spacecraft.
    static Time
    ETT2SCET(Time ETT, int sc_id)
    Returns the input earth transmit time + the upleg time to the spacecraft.
    floor(Duration resolution)
    Rounds the time down to the input resolution, based on the reference time.
    floor(Duration resolution, Time referenceTime)
    Rounds the time down to the input resolution, based on the reference time.
    static Time
    fromET(double ephemerisTime)
    Creates a Time object from Spice ET seconds
    static Time
    fromExcelUTC(String excelFormattedDate)
    Turns excel-formatted UTC datetime string into Time object.
    static Time
    fromGPS(String gpsString)
     
    static Time
    fromGPSSeconds(double gpsSeconds)
     
    static Time
    Returns a Time object equivalent to the input LMST string.
    static Time
    fromLMST(String lmst, int sc_id)
    Returns a Time object equivalent to the input LMST string
    static Time
    fromSCLK(String sclk_string)
    Returns a Time object that is equivalent to a given SCLK string.
    static Time
    fromSCLK(String sclk_string, int sc_id)
    Returns a Time object that is equivalent to a given SCLK string
    static Time
    fromSCLKD(double sclkd)
    Creates a time object given a SCLK decimal.
    static Time
    fromSCLKD(double sclkd, int sc_id)
    Creates a time object given a SCLK decimal and a SC NAIF id
    static Time
    fromTAI(double TAI)
    Creates a Time object from Spice TAI seconds
    static Time
    Creates a time object from a time in the TDB (Spice ET) system formatted in ISOC
    static Time
    fromTics(long tics)
    Creates a time object given the number of tics (NOT seconds).
    static Time
    Returns a new Time object given a Java ZonedDateTime - converts to UTC, then feeds that String to standard Time constructor
    static Time
    fromTimezoneString(String timeString, String timezone)
    Returns a new Time object given a local Time and the timezone that Time is in - converts to UTC, then feeds that String to standard Time constructor
    static String
    Returns the default LST body frame and checks that it is not null.
    static Integer
    Returns the current default spacecraft id and checks to make sure that it is not null.
    static int
    Returns the current default output decimal precision.
    static Time
     
    static int
    Returns the current default spacecraft id and checks to make sure that it is not null.
    static Time
     
     
    For XMLTOL use only - in UTC seconds since 1970 since that is the spec
    long
     
     
    static Time
     
    boolean
    Returns true if the parameter is after the calling object in time
    boolean
    Returns true if the parameter is after the calling object in time or if they represent the same time
    int
     
    boolean
    Returns true if the parameter is before the calling object in time
    boolean
    Returns true if the parameter is before the calling object in time or if they represent the same time
    static Time
    max(Time... times)
    Returns the latest of a list of times.
    static Time
    min(Time... times)
    Returns the earliest of a list of times.
    Syntactic sugar for subtract(Duration)
    minus(Time t2)
    Syntactic sugar for subtract(Time)
    Syntactic sugar for add()
    round(Duration resolution)
    Rounds the time to the input resolution, based on the reference time.
    round(Duration resolution, Time referenceTime)
    Rounds the time to the input resolution, based on the reference time.
    rtlt(Time t, int sc_id, int body_id, boolean forwardsInTime, String time_reference)
    Returns the RTLT as a duration object.
    static Time
    SCET2ERT(Time SCET)
    Returns the input spacecraft event time + the downleg time from the spacecraft.
    static Time
    SCET2ERT(Time SCET, int sc_id)
    Returns the input spacecraft event time + the downleg time from the spacecraft.
    static Time
    SCET2ETT(Time SCET)
    Returns the input spacecraft time - the upleg time to the spacecraft.
    static Time
    SCET2ETT(Time SCET, int sc_id)
    Returns the input spacecraft time - the upleg time to the spacecraft.
    static void
    setDefaultLstBodyFrame(String defaultLstBodyFrame)
    Sets the default LST body frame, which is tied to the naif body id.
    static void
    Updates the default body id for LST methods.
    static void
    setDefaultOutputPrecision(int defaultOutputPrecision)
    Sets the default output decimal precision.
    static void
    Updates the default spacecraft id for convenience methods.
    static void
    Call this before trying time frame conversions if you don't want to use SPICE for lighttime
    static void
    setUseSpiceForMath(boolean shouldUseSpiceForMath)
    call this before you start making Time objects if you want Java datetime to do the conversion to and from strings instead of SPICE
    Subtracting a duration from a Time returns another Time
    Subtracting two times returns a duration
    Outputs a string representing a time with the default number of decimal precision
    toCalendar(int precision)
    Outputs a string representing a time with the given number of decimal precision
    double
    Converts the calling Time object to Spice ephemeris time
     
    toExcelUTC(boolean fourDigitYear)
     
    double
    The calling object Time expressed as a sol-fraction since the LMST epoch.
    double
    toFractionalSols(int sc_id)
    The calling object Time expressed as a sol-fraction since the LMST epoch.
    toGPS(int precision)
     
    double
     
    Outputs a string representing a time with the default number of decimal precision
    toISOC(int precision)
    Outputs a string representing a time with the given number of decimal precision
    Outputs a string representing a time with the default number of decimal precision
    toJulian(int precision)
    Outputs a string representing a time with the given number of decimal precision
    Wraps toLMST but uses default spacecraft id and precision
    toLMST(int precision)
    Wraps toLMST but uses default spacecraft id.
    toLMST(int sc_id, int precision)
    Outputs a string that represents this instant in Local Mean Solar Time (LMST) for the SC specified
    Returns whether or not the LMST time is before noon as an AM_PM enum object.
    toLmstAmPm(int sc_id)
    Returns whether or not the LMST time is before noon as an AM_PM enum object.
    Wraps toLST but uses default spacecraft id, body id and frame.
    toLST(int sc_id)
    Wraps toLST but uses default body id and frame.
    toLST(int sc_id, int body_id, String body_frame)
    Gets the local solar time at a SC's location given that body ID and body frame.
    Wraps toLTST but uses default spacecraft id, body id and body frame.
    toLTST(int sc_id)
    Wraps toLTST but uses default body id and frame.
    toLTST(int sc_id, int body_id, String body_frame)
    Calculates the LMST-assisted Local True Solar Time (LTST) value for the calling Time object.
    Outputs the SCLK string that is equivalent to the calling object.
    toSCLK(int sc_id)
    Outputs the SCLK string that is equivalent to the calling object.
    double
    Outputs the SCLK decimal that is equivalent to the calling object.
    double
    toSCLKD(int sc_id)
    Outputs the SCLK decimal that is equivalent to the calling object.
    int
    The integer sol number at the calling object Time.
    int
    toSolNumber(int sc_id)
    The integer sol number at the calling object Time.
    Overrides the default toString() method so you get a default representation of the object.
    double
    Outputs a double representing the time in SPICE TAI
    toTimezone(String timezone)
    Returns a ZonedDateTime that is equivalent to the calling Time object.
    Wraps toTimezoneString but uses default precision.
    toTimezoneString(String timezone, int precision)
    Returns a string representing the calling object instant moved to a different timezone
    Returns a utc string with the default precision.
    toUTC(int precision)
    Outputs a string representing a time with the given number of decimal precision
    Returns whether or not the UTC time is before noon as an AM_PM enum object.
    static Duration
    Wraps upleg(t, sc_id, body_id), but always passes body_id = EARTH_NAIF_ID (Earth) Uses default spacecraft id
    static Duration
    upleg(Time t, int sc_id)
    Wraps upleg(t, sc_id, body_id), but always passes body_id = EARTH_NAIF_ID (Earth)
    static Duration
    upleg(Time t, int sc_id, int body_id)
    Wraps upleg(t, sc_id, body_id, time_reference) but always passes in "SCET" as time reference
    void
    valueOf(String utcFormattedString)
    Given a UTC time format (anything allowed by str2et), mutates the calling object to represent that time Implements the convertableFromString interface so engines can call valueOf on whatever object including Times.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • Time

      public Time(String t)
      The main Time constructor, that wraps str2et in SPICE if it is enabled, or a Java DateTime if it is not.
      Parameters:
      t - Time string. When using SPICE, it can be any of the input formats that str2et supports (there are a lot)
    • Time

      protected Time(long tics)
      This protected constructor is used by the fromX and valueOf methods to actually assign the backing data.
    • Time

      public Time()
      This is the empty time constructor, which will use 0 tics for the time input. It is needed when you need to create Time objects then assign them a value later (which should be a rare case).
    • Time

      public Time(Time t2)
      Copy constructor, also used for EpochRelativeTime
  • Method Details

    • setUseSpiceForMath

      public static void setUseSpiceForMath(boolean shouldUseSpiceForMath)
      call this before you start making Time objects if you want Java datetime to do the conversion to and from strings instead of SPICE
    • setDefaultSpacecraftId

      public static void setDefaultSpacecraftId(Integer spacecraftId)
      Updates the default spacecraft id for convenience methods.
      Parameters:
      spacecraftId -
    • setLightTimeProvider

      public static void setLightTimeProvider(LightTimeProvider inProvider)
      Call this before trying time frame conversions if you don't want to use SPICE for lighttime
    • getDefaultSpacecraftId

      public static int getDefaultSpacecraftId()
      Returns the current default spacecraft id and checks to make sure that it is not null.
      Returns:
    • setDefaultLstBodyId

      public static void setDefaultLstBodyId(Integer bodyId)
      Updates the default body id for LST methods. This would be set to 499 for Mars surface missions, for example.
      Parameters:
      bodyId -
    • getDefaultLstBodyId

      public static Integer getDefaultLstBodyId()
      Returns the current default spacecraft id and checks to make sure that it is not null.
      Returns:
    • setDefaultLstBodyFrame

      public static void setDefaultLstBodyFrame(String defaultLstBodyFrame)
      Sets the default LST body frame, which is tied to the naif body id.
      Parameters:
      defaultLstBodyFrame -
    • getDefaultLstBodyFrame

      public static String getDefaultLstBodyFrame()
      Returns the default LST body frame and checks that it is not null.
      Returns:
    • setDefaultOutputPrecision

      public static void setDefaultOutputPrecision(int defaultOutputPrecision)
      Sets the default output decimal precision.
      Parameters:
      defaultOutputPrecision -
    • getDefaultOutputPrecision

      public static int getDefaultOutputPrecision()
      Returns the current default output decimal precision.
      Returns:
    • getUnixEpoch

      public static Time getUnixEpoch()
      Returns:
      A Time object representing the Unix 0 time
    • getGPSEpoch

      public static Time getGPSEpoch()
      Returns:
      A Time object representing the GPS epoch
    • getDefaultReferenceTime

      public static Time getDefaultReferenceTime()
      Returns:
      A time object representing Jan 1 2000 00:00:00, to give a reference for time rounding up or down
    • getTics

      public long getTics()
      Returns:
      returns the number of 10-nanosecond tics since the reference time 2000-001T12:00:00 (not exactly) - DO NOT use this to do your own manual math, just for I/O
    • add

      public Time add(Duration d)
      Adding a time and duration returns a time
      Parameters:
      d - The Duration you want to add to the calling Time object
      Returns:
      A new Time object
    • plus

      public Time plus(Duration d)
      Syntactic sugar for add()
      Parameters:
      d -
      Returns:
      A new Time object
    • subtract

      public Time subtract(Duration d)
      Subtracting a duration from a Time returns another Time
      Parameters:
      d - The Duration you want to subtract from the calling Time object
      Returns:
      A new Time object
    • minus

      public Time minus(Duration d)
      Syntactic sugar for subtract(Duration)
      Parameters:
      d -
      Returns:
      A new Time object
    • subtract

      public Duration subtract(Time t2)
      Subtracting two times returns a duration
      Parameters:
      t2 - The time you want to subtract from the calling Time object
      Returns:
      A new Duration object representing the length of time elapsed from the parameter to the calling object
    • minus

      public Duration minus(Time t2)
      Syntactic sugar for subtract(Time)
      Parameters:
      t2 -
      Returns:
      A new Duration object
    • absoluteDifference

      public Duration absoluteDifference(Time t2)
      Returns a Duration that is the absolute difference between the calling object and the parameter
      Parameters:
      t2 - The time you want to get the positive difference from
      Returns:
      A new Duration object that is the absolute difference
    • lessThan

      public boolean lessThan(Time t2)
      Returns true if the parameter is before the calling object in time
      Parameters:
      t2 - The second time to compare to
      Returns:
      a boolean
    • greaterThan

      public boolean greaterThan(Time t2)
      Returns true if the parameter is after the calling object in time
      Parameters:
      t2 - The second time to compare to
      Returns:
      a boolean
    • lessThanOrEqualTo

      public boolean lessThanOrEqualTo(Time t2)
      Returns true if the parameter is before the calling object in time or if they represent the same time
      Parameters:
      t2 - The second time to compare to
      Returns:
      a boolean
    • greaterThanOrEqualTo

      public boolean greaterThanOrEqualTo(Time t2)
      Returns true if the parameter is after the calling object in time or if they represent the same time
      Parameters:
      t2 - The second time to compare to
      Returns:
      a boolean
    • min

      public static Time min(Time... times)
      Returns the earliest of a list of times. Wraps Collections.min()
      Parameters:
      times - Time objects
      Returns:
      A time object
    • max

      public static Time max(Time... times)
      Returns the latest of a list of times. Wraps Collections.max()
      Parameters:
      times - Time objects
      Returns:
      A time object
    • round

      public Time round(Duration resolution)
      Rounds the time to the input resolution, based on the reference time. Uses midnight utc for reference time.
      Parameters:
      resolution -
      Returns:
    • round

      public Time round(Duration resolution, Time referenceTime)
      Rounds the time to the input resolution, based on the reference time. For example, with a reference time of 2019-001T00:00:00 and resolution of 00:05:00 2019-001T00:33:00 would be rounded to 2019-001T00:35:00, but with a reference time of 2019-001T00:00:01 the same input time would be rounded to 2019-001T00:35:01.
      Parameters:
      resolution -
      referenceTime -
      Returns:
    • ceil

      public Time ceil(Duration resolution)
      Rounds the time up to the input resolution, based on the reference time. Uses midnight utc for reference time.
      Parameters:
      resolution -
      Returns:
    • ceil

      public Time ceil(Duration resolution, Time referenceTime)
      Rounds the time up to the input resolution, based on the reference time. See explanation in round method for reference time.
      Parameters:
      resolution -
      referenceTime -
      Returns:
    • floor

      public Time floor(Duration resolution)
      Rounds the time down to the input resolution, based on the reference time. Uses midnight utc for reference time.
      Parameters:
      resolution -
      Returns:
    • floor

      public Time floor(Duration resolution, Time referenceTime)
      Rounds the time down to the input resolution, based on the reference time. See explanation in round method for reference time.
      Parameters:
      resolution -
      referenceTime -
      Returns:
    • equalToWithin

      public boolean equalToWithin(Time t2, Duration resolution)
      Compares the time to another time object and returns true if t2 is within an input resolution of t1.
      Parameters:
      t2 -
      resolution -
      Returns:
    • getMidnightUTC

      public Time getMidnightUTC()
      Returns:
      A Time object that equals midnight on the current day UTC
    • getTimeOfDay

      public Duration getTimeOfDay()
      Returns:
      A duration representing the elapsed duration since midnight UTC for this Time
    • toString

      public String toString()
      Overrides the default toString() method so you get a default representation of the object. In this case, we are using UTC format with the default number of decimal places. To get other string methods, use toX() methods
      Overrides:
      toString in class Object
      Returns:
    • valueOf

      public void valueOf(String utcFormattedString)
      Given a UTC time format (anything allowed by str2et), mutates the calling object to represent that time Implements the convertableFromString interface so engines can call valueOf on whatever object including Times.
      Specified by:
      valueOf in interface ConvertableFromString
      Parameters:
      utcFormattedString -
    • toUTC

      public String toUTC()
      Returns a utc string with the default precision.
      Returns:
    • toUTC

      public String toUTC(int precision)
      Outputs a string representing a time with the given number of decimal precision
      Parameters:
      precision - An integer, the number of decimal places put out by the function
      Returns:
      A string representing the time in UTC DOY format
    • toTAI

      public double toTAI()
      Outputs a double representing the time in SPICE TAI
      Returns:
      A double, SPICE TAI of the instant of this object
    • fromTAI

      public static Time fromTAI(double TAI)
      Creates a Time object from Spice TAI seconds
      Parameters:
      TAI - Spice TAI seconds
      Returns:
      A new Time object
    • toET

      public double toET()
      Converts the calling Time object to Spice ephemeris time
      Returns:
      A double of the Spice ET equivalent to the calling object
    • fromET

      public static Time fromET(double ephemerisTime)
      Creates a Time object from Spice ET seconds
      Parameters:
      ephemerisTime - Spice ET seconds
      Returns:
      A new Time object
    • fromTDBString

      public static Time fromTDBString(String etString)
      Creates a time object from a time in the TDB (Spice ET) system formatted in ISOC
      Parameters:
      etString - A time in TDB in ISOC. Example: 2027-04-30T02:17:09.8354
      Returns:
      the equivalent Time object
    • toISOC

      public String toISOC()
      Outputs a string representing a time with the default number of decimal precision
      Returns:
      A string representing the time in ISOC format
    • toISOC

      public String toISOC(int precision)
      Outputs a string representing a time with the given number of decimal precision
      Parameters:
      precision - An integer, the number of decimal places put out by the function
      Returns:
      A string representing the time in ISOC format
    • toJulian

      public String toJulian()
      Outputs a string representing a time with the default number of decimal precision
      Returns:
      A string representing the time in Julian date format
    • toJulian

      public String toJulian(int precision)
      Outputs a string representing a time with the given number of decimal precision
      Parameters:
      precision - An integer, the number of decimal places put out by the function
      Returns:
      A string representing the time in Julian date format
    • toCalendar

      public String toCalendar()
      Outputs a string representing a time with the default number of decimal precision
      Returns:
      A string representing the time in UTC calendar format
    • toCalendar

      public String toCalendar(int precision)
      Outputs a string representing a time with the given number of decimal precision
      Parameters:
      precision - An integer, the number of decimal places put out by the function
      Returns:
      A string representing the time in UTC calendar format
    • toUtcAmPm

      public Time.AM_PM toUtcAmPm()
      Returns whether or not the UTC time is before noon as an AM_PM enum object.
      Returns:
    • toSCLK

      public String toSCLK()
      Outputs the SCLK string that is equivalent to the calling object. Uses Spice sce2s with the default spacecraft id
      Returns:
      This time's SCLK string
    • toSCLK

      public String toSCLK(int sc_id)
      Outputs the SCLK string that is equivalent to the calling object. Uses Spice sce2s
      Parameters:
      sc_id - The NAIF ID of the spacecraft whose SCLK it is. This is typically a negative 3 digit number.
      Returns:
      This time's SCLK string
    • fromSCLK

      public static Time fromSCLK(String sclk_string)
      Returns a Time object that is equivalent to a given SCLK string. Uses default spacecraft id.
      Parameters:
      sclk_string - The SCLK string itself - must be in a format that Spice scs2e can understand
      Returns:
      A new Time object
    • fromSCLK

      public static Time fromSCLK(String sclk_string, int sc_id)
      Returns a Time object that is equivalent to a given SCLK string
      Parameters:
      sclk_string - The SCLK string itself - must be in a format that Spice scs2e can understand
      sc_id - The NAIF ID of the spacecraft whose SCLK it is. This is typically a negative 3 digit number.
      Returns:
      A new Time object
    • toSCLKD

      public double toSCLKD()
      Outputs the SCLK decimal that is equivalent to the calling object. Uses sce2s then converts to a decimal. Automatically figures out the SCLK sub-second modulus by calling gdpool on the SCLK kernel. Uses default spacecraft id.
      Returns:
      This time's SCLK decimal
    • toSCLKD

      public double toSCLKD(int sc_id)
      Outputs the SCLK decimal that is equivalent to the calling object. Uses sce2s then converts to a decimal. Automatically figures out the SCLK sub-second modulus by calling gdpool on the SCLK kernel
      Parameters:
      sc_id - The NAIF ID of the spacecraft whose SCLK it is. This is typically a negative 3 digit number.
      Returns:
      This time's SCLK decimal
    • fromSCLKD

      public static Time fromSCLKD(double sclkd)
      Creates a time object given a SCLK decimal. Uses default spacecraft id.
      Parameters:
      sclkd - The SCLK decimal itself - a float number of seconds
      Returns:
      A new Time object
    • fromSCLKD

      public static Time fromSCLKD(double sclkd, int sc_id)
      Creates a time object given a SCLK decimal and a SC NAIF id
      Parameters:
      sclkd - The SCLK decimal itself - a float number of seconds
      sc_id - The NAIF ID of the spacecraft whose SCLK it is. This is typically a negative 3 digit number.
      Returns:
      A new Time object
    • fromTics

      public static Time fromTics(long tics)
      Creates a time object given the number of tics (NOT seconds). DO NOT use this to do your own time math, this is just for I/O
      Parameters:
      tics - The number of 10-nanosecond tics since the reference time 2000-001T12:00:00 (not exactly).
      Returns:
      A new Time object
    • toLMST

      public String toLMST()
      Wraps toLMST but uses default spacecraft id and precision
      Returns:
      LMST string
    • toLMST

      public String toLMST(int precision)
      Wraps toLMST but uses default spacecraft id.
      Parameters:
      precision - precision for output string
      Returns:
      LMST string
    • toLMST

      public String toLMST(int sc_id, int precision)
      Outputs a string that represents this instant in Local Mean Solar Time (LMST) for the SC specified
      Parameters:
      sc_id - The NAIF ID of the spacecraft. This is typically a negative 3 digit number. To get the separate LMST SCLK ID/landing site ID, this routine multiplies by -1 then appends '900', which is the NAIF unofficial standard
      precision - The number of decimal places that should be included in the output
      Returns:
      The calling object represented as an LMST string
    • fromLMST

      public static Time fromLMST(String lmst)
      Returns a Time object equivalent to the input LMST string. Uses default spacecraft id.
      Parameters:
      lmst - The LMST string - many different formats are accepted (the standard is Sol-####M##:##:##.###)
      Returns:
      A new Time object
    • fromLMST

      public static Time fromLMST(String lmst, int sc_id)
      Returns a Time object equivalent to the input LMST string
      Parameters:
      lmst - The LMST string - many different formats are accepted (the standard is Sol-####M##:##:##.###)
      sc_id - The NAIF ID of the spacecraft. This is typically a negative 3 digit number. To get the separate LMST SCLK ID/landing site ID, this routine multiplies by -1 then appends '900', which is the NAIF unofficial standard
      Returns:
      A new Time object
    • toLmstAmPm

      public Time.AM_PM toLmstAmPm()
      Returns whether or not the LMST time is before noon as an AM_PM enum object. Uses default spacecraft id.
      Returns:
    • toLmstAmPm

      public Time.AM_PM toLmstAmPm(int sc_id)
      Returns whether or not the LMST time is before noon as an AM_PM enum object.
      Parameters:
      sc_id -
      Returns:
    • toSolNumber

      public int toSolNumber()
      The integer sol number at the calling object Time. First calls toLMST() then uses regex to get the sol number. Uses default spacecraft id
      Returns:
      An integer of the sol number at the Time queried
    • toSolNumber

      public int toSolNumber(int sc_id)
      The integer sol number at the calling object Time. First calls toLMST() then uses regex to get the sol number.
      Parameters:
      sc_id - The NAIF ID of the spacecraft. This is typically a negative 3 digit number. To get the separate LMST SCLK ID/landing site ID, this routine multiplies by -1 then appends '900', which is the NAIF unofficial standard
      Returns:
      An integer of the sol number at the Time queried
    • toFractionalSols

      public double toFractionalSols()
      The calling object Time expressed as a sol-fraction since the LMST epoch. For example, Sol-0026M12:00:00 is 26.5. First calls LMST() then converts HH:MM:SS to decimal. Uses default spacecraft id.
      Returns:
      A double of the fractional sols elapsed since the LMST epoch
    • toFractionalSols

      public double toFractionalSols(int sc_id)
      The calling object Time expressed as a sol-fraction since the LMST epoch. For example, Sol-0026M12:00:00 is 26.5. First calls LMST() then converts HH:MM:SS to decimal
      Parameters:
      sc_id - The NAIF ID of the spacecraft. This is typically a negative 3 digit number. To get the separate LMST SCLK ID/landing site ID, this routine multiplies by -1 then appends '900', which is the NAIF unofficial standard
      Returns:
      A double of the fractional sols elapsed since the LMST epoch
    • toLST

      public Duration toLST()
      Wraps toLST but uses default spacecraft id, body id and frame.
      Returns:
      LST duration (time of day)
    • toLST

      public Duration toLST(int sc_id)
      Wraps toLST but uses default body id and frame.
      Parameters:
      sc_id - naif id of spacecraft
      Returns:
      LST duration (time of day)
    • toLST

      public Duration toLST(int sc_id, int body_id, String body_frame)
      Gets the local solar time at a SC's location given that body ID and body frame. This returns just a Duration between 0 and 24 hours, since with just this information and no epoch it is impossible to have a true time system. To get the hours, minutes, seconds from the resulting duration object, you can call .toHours(), toMinutes()%60, and toSeconds%60
      Parameters:
      sc_id - The SC at whose position you want to know the local solar time
      body_id - The NAIF ID of the body that the spacecraft is on or orbiting
      body_frame - The NAIF frame string for the body the spacecraft is on or orbiting
      Returns:
      A duration object between 0 and 24 hours in magnitude that contains the local solar time of the point on the given body
    • toLTST

      public String toLTST()
      Wraps toLTST but uses default spacecraft id, body id and body frame.
      Returns:
      LTST string
    • toLTST

      public String toLTST(int sc_id)
      Wraps toLTST but uses default body id and frame.
      Parameters:
      sc_id - naif spacecraft id
      Returns:
      LTST string
    • toLTST

      public String toLTST(int sc_id, int body_id, String body_frame)
      Calculates the LMST-assisted Local True Solar Time (LTST) value for the calling Time object. What this means is that this routine first calls toLST() to get the time of day, then infers the sol number from LMST (correcting if you need to add or subtract one sol over the midnight boundary). This means you have to have all the LMST kernels loaded to call this.
      Parameters:
      sc_id - The SC at whose position you want to know the local true solar time
      body_id - The NAIF ID of the body that the spacecraft is on or orbiting
      body_frame - The NAIF frame string for the body the spacecraft is on or orbiting
      Returns:
      The calling object represented as an LTST string
    • toTimezone

      public ZonedDateTime toTimezone(String timezone)
      Returns a ZonedDateTime that is equivalent to the calling Time object. This is useful because ZonedDateTime has a lot of nice utility methods like DayOfWeek, getHours, etc etc that we don't have to wrap in this class
      Parameters:
      timezone - The timezone string you want to convert the time into. It must be a string acceptable to the ZoneId.of() method
      Returns:
      A ZonedDateTime object representing the same time in a different timezone
    • toTimezoneString

      public String toTimezoneString(String timezone)
      Wraps toTimezoneString but uses default precision.
      Parameters:
      timezone - The timezone string you want to represent the instant in. It must be a string acceptable to the ZoneId.of() method
      Returns:
      A string that contains the time in a different timezone
    • toTimezoneString

      public String toTimezoneString(String timezone, int precision)
      Returns a string representing the calling object instant moved to a different timezone
      Parameters:
      timezone - The timezone string you want to represent the instant in. It must be a string acceptable to the ZoneId.of() method
      precision - decimal precision to use for outputting the string
      Returns:
      A string that contains the time in a different timezone
    • fromTimezoneString

      public static Time fromTimezoneString(String timeString, String timezone)
      Returns a new Time object given a local Time and the timezone that Time is in - converts to UTC, then feeds that String to standard Time constructor
      Parameters:
      timeString - A local time, in the YYYY-DDDTHH:MM:SS.ssssss format
      timezone - The timezone string you want to convert the time into. It must be a string acceptable to the ZoneId.of() method
      Returns:
      A new Time object
    • fromTimezone

      public static Time fromTimezone(ZonedDateTime zdt)
      Returns a new Time object given a Java ZonedDateTime - converts to UTC, then feeds that String to standard Time constructor
      Parameters:
      zdt - The input ZonedDateTime
      Returns:
      A new Time object
    • toGPSSeconds

      public double toGPSSeconds()
      Returns:
      A double of the GPS seconds equivalent to the calling object
    • fromGPSSeconds

      public static Time fromGPSSeconds(double gpsSeconds)
      Returns:
      A Time equivalent to the input gps time as seconds
    • toGPS

      public String toGPS(int precision)
      Returns:
      The time represented as a GPS string
    • fromGPS

      public static Time fromGPS(String gpsString)
      Parameters:
      gpsString - A time string in the GPS time system
      Returns:
      A time object equivalent to the input string
    • toExcelUTC

      public String toExcelUTC(boolean fourDigitYear)
      Returns:
      the Time represented as an excel-formatted UTC String with either 2 or 4 digit years
    • toExcelUTC

      public String toExcelUTC()
      Returns:
      the Time represented as an excel-formatted UTC String with a 2-digit year
    • fromExcelUTC

      public static Time fromExcelUTC(String excelFormattedDate)
      Turns excel-formatted UTC datetime string into Time object. Assumes any 2-digit years are 20xx
      Parameters:
      excelFormattedDate - String in format mm/dd/yy hh:mm(:ss), an example is '02/21/19 18:45'
      Returns:
    • getMilliseconds

      public String getMilliseconds()
      For XMLTOL use only - in UTC seconds since 1970 since that is the spec
      Returns:
      A string whose contents are milliseconds since Unix epoch
    • currentSystemTime

      public static Time currentSystemTime()
      Return the current system time as a Time object.
      Returns:
    • ETT2SCET

      public static Time ETT2SCET(Time ETT)
      Returns the input earth transmit time + the upleg time to the spacecraft. Uses default spacecraft id.
      Parameters:
      ETT - A Time object in ETT
      Returns:
      A new Time object shifted by OWLT
    • ETT2SCET

      public static Time ETT2SCET(Time ETT, int sc_id)
      Returns the input earth transmit time + the upleg time to the spacecraft.
      Parameters:
      ETT - A Time object in ETT
      sc_id - The NAIF id of the spacecraft for which you want the SpaceCraft Event Time
      Returns:
      A new Time object shifted by OWLT
    • ETT2ERT

      public static Time ETT2ERT(Time ETT)
      Returns the input earth transmit time + the upleg time to the spacecraft + the downleg time from the spacecraft when the signal arrives at the spacecraft. Uses default spacecraft id.
      Parameters:
      ETT - A Time object in ETT
      Returns:
      A new Time object shifted by RTLT
    • ETT2ERT

      public static Time ETT2ERT(Time ETT, int sc_id)
      Returns the input earth transmit time + the upleg time to the spacecraft + the downleg time from the spacecraft when the signal arrives at the spacecraft.
      Parameters:
      ETT - A Time object in ETT
      sc_id - The NAIF id of the spacecraft that light is traveling to and from
      Returns:
      A new Time object shifted by RTLT
    • ERT2ETT

      public static Time ERT2ETT(Time ERT)
      Returns the input earth receive time - the downleg time from the spacecraft - the upleg time to the spacecraft when the signal was sent. Uses default spacecraft id
      Parameters:
      ERT - A Time object in ERT
      Returns:
      A new Time objected shifted by RTLT
    • ERT2ETT

      public static Time ERT2ETT(Time ERT, int sc_id)
      Returns the input earth receive time - the downleg time from the spacecraft - the upleg time to the spacecraft when the signal was sent.
      Parameters:
      ERT - A Time object in ERT
      sc_id - The NAIF id of the spacecraft that light is traveling to and from
      Returns:
      A new Time objected shifted by RTLT
    • SCET2ERT

      public static Time SCET2ERT(Time SCET)
      Returns the input spacecraft event time + the downleg time from the spacecraft. Uses default spacecraft id and earth naif id.
      Parameters:
      SCET - A Time object in SCET
      Returns:
      A new Time object shifted by OWLT
    • SCET2ERT

      public static Time SCET2ERT(Time SCET, int sc_id)
      Returns the input spacecraft event time + the downleg time from the spacecraft.
      Parameters:
      SCET - A Time object in SCET
      sc_id - The Naif id of the spacecraft that the SCET is tied to
      Returns:
      A new Time object shifted by OWLT
    • SCET2ETT

      public static Time SCET2ETT(Time SCET)
      Returns the input spacecraft time - the upleg time to the spacecraft. Uses default spacecraft id.
      Parameters:
      SCET - A Time object in SCET
      Returns:
      A new Time object shifted by OWLT
    • SCET2ETT

      public static Time SCET2ETT(Time SCET, int sc_id)
      Returns the input spacecraft time - the upleg time to the spacecraft.
      Parameters:
      SCET - A Time object in SCET
      sc_id - The Naif id of the spacecraft that the SCET is tied to
      Returns:
      A new Time object shifted by OWLT
    • ERT2SCET

      public static Time ERT2SCET(Time ERT)
      Returns the input spacecraft event time - upleg time to the spacecraft. Uses default spacecraft id.
      Parameters:
      ERT - A Time object in ERT
      Returns:
      A new Time objected shifted by OWLT
    • ERT2SCET

      public static Time ERT2SCET(Time ERT, int sc_id)
      Returns the input spacecraft event time - upleg time to the spacecraft.
      Parameters:
      ERT - A Time object in ERT
      sc_id - The NAIF id of the spacecraft for which you want the SpaceCraft Event Time
      Returns:
      A new Time objected shifted by OWLT
    • upleg

      public static Duration upleg(Time t)
      Wraps upleg(t, sc_id, body_id), but always passes body_id = EARTH_NAIF_ID (Earth) Uses default spacecraft id
      Parameters:
      t -
      Returns:
    • upleg

      public static Duration upleg(Time t, int sc_id)
      Wraps upleg(t, sc_id, body_id), but always passes body_id = EARTH_NAIF_ID (Earth)
      Parameters:
      t -
      sc_id -
      Returns:
    • upleg

      public static Duration upleg(Time t, int sc_id, int body_id)
      Wraps upleg(t, sc_id, body_id, time_reference) but always passes in "SCET" as time reference
      Parameters:
      t -
      sc_id -
      body_id -
      Returns:
    • downleg

      public static Duration downleg(Time t)
      Wraps downleg(t, sc_id, body_id), but always passes body_id = EARTH_NAIF_ID (Earth) Uses default spacecraft id.
      Parameters:
      t -
      Returns:
    • downleg

      public static Duration downleg(Time t, int sc_id)
      Wraps downleg(t, sc_id, body_id), but always passes body_id = EARTH_NAIF_ID (Earth)
      Parameters:
      t -
      sc_id -
      Returns:
    • downleg

      public static Duration downleg(Time t, int sc_id, int body_id)
      Wraps downleg(t, sc_id, body_id, time_reference) but always passes in "SCET" as time reference
      Parameters:
      t -
      sc_id -
      body_id -
      Returns:
    • rtlt

      public Duration rtlt(Time t, int sc_id, int body_id, boolean forwardsInTime, String time_reference)
      Returns the RTLT as a duration object.
      Returns:
    • compareTo

      public int compareTo(Time t2)
      Specified by:
      compareTo in interface Comparable<Time>
    • equals

      public boolean equals(Object t2)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object