Class StixInstant

java.lang.Object
security.whisper.javastix.common.StixInstant

public class StixInstant extends Object
Stores a Java.time Instant and stores the original sub-second precision digital count. SubSecond precision count means that the number of digits (even if all zeros / trailing zeros) are remembered. Use toString() to get the Stix string format for the datetime.
  • Field Details

    • REGEX_SUBSECOND

      public static final Pattern REGEX_SUBSECOND
  • Constructor Details

    • StixInstant

      public StixInstant()
      Generates a Instant.now() Defaults to 3 digits of sub second precision (milliseconds)
    • StixInstant

      public StixInstant(Instant instant, int subSecondPrecision)
    • StixInstant

      public StixInstant(Instant instant)
      Defaults with parsed Instant's Nano second precision digit count. Note that trailing zeros would have been stripped. If you need to keep exact precision, including the trailing zeros, use StixInstant(Instant, int)
  • Method Details

    • now

      public static StixInstant now()
      Static factory method for creating a StixInstant with the current time. Defaults to 3 digits of sub second precision (milliseconds). This is the preferred way to create a StixInstant representing "now".
      Returns:
      A new StixInstant representing the current moment
    • getInstant

      public Instant getInstant()
      Get the underlying Instant value. If you need the Stix Date with the Stix Precision then use toString() getInstant() should only be used in special cases where you need access to perform temporal work.
    • getOriginalSubSecondPrecisionDigitCount

      public int getOriginalSubSecondPrecisionDigitCount()
    • toString

      public String toString()
      Generates a STIX Spec String of DateTime. Uses StixDataFormats.getWriterStixDateTimeFormatter(int)
      Overrides:
      toString in class Object
    • toString

      public String toString(int subSecondPrecision)
    • parse

      public static StixInstant parse(String dateString)