Class TemporalUtilities

java.lang.Object
org.apache.sis.util.Static
org.apache.sis.internal.util.TemporalUtilities

public final class TemporalUtilities extends Static
Utilities related to ISO 19108 objects. This class may disappear after we reviewed the GeoAPI-pending temporal interfaces.
Since:
0.3
Version:
1.2
  • Constructor Details

    • TemporalUtilities

      private TemporalUtilities()
      Do not allow instantiation of this class.
  • Method Details

    • getTemporalFactory

      public static TemporalFactory getTemporalFactory() throws UnsupportedOperationException
      Returns a temporal factory if available.
      Returns:
      the temporal factory.
      Throws:
      UnsupportedOperationException - if the temporal factory is not available on the classpath.
    • createInstant

      private static Instant createInstant(TemporalFactory factory, Date date)
      Creates an instant for the given date using the given factory.
    • createInstant

      public static Instant createInstant(Date time) throws UnsupportedOperationException
      Creates an instant for the given date.
      Parameters:
      time - the date for which to create instant, or null.
      Returns:
      the instant, or null if the given time was null.
      Throws:
      UnsupportedOperationException - if the temporal factory is not available on the classpath.
    • createPeriod

      public static Period createPeriod(Date begin, Date end) throws UnsupportedOperationException
      Creates a period for the given begin and end dates. The given arguments can be null if the TemporalFactory.createInstant(Date) method accepts null dates, which stand for undetermined position.
      Parameters:
      begin - the begin date, inclusive.
      end - the end date, inclusive.
      Returns:
      the period.
      Throws:
      UnsupportedOperationException - if the temporal factory is not available on the classpath.
    • getDate

      public static Date getDate(org.opengis.temporal.TemporalPrimitive time)
      Infers a value from the extent as a Date object. This method is used for compatibility with legacy API and may disappear in future SIS version.
      Parameters:
      time - the instant or period for which to get a date, or null.
      Returns:
      the requested time as a Java date, or null if none.
      Since:
      1.0
    • toDate

      public static Date toDate(Instant instant)
      Temporary method, to be removed after we upgraded metadata to java.time.
      Parameters:
      instant - the Java instant, or null.
      Returns:
      the legacy Java date, or null.