Class Time

java.lang.Object
org.simplesim.core.scheduling.Time
All Implemented Interfaces:
Comparable<Time>

public final class Time extends Object implements Comparable<Time>
Provides time and calendar functionality to scale and navigate the simulation's time axis.

Ticks are stored as long primitive. A time scale is provided, standardized with one second set to one. The scale may be changed because within the simulator, only the Time wrapper is used.

This class is immutable and thus tread safe.

  • Field Details

  • Constructor Details

    • Time

      public Time(long value)
      Basic constructor
      Parameters:
      value - number of ticks
    • Time

      public Time(Time time)
      Copy constructor
      Parameters:
      time - time to duplicate
    • Time

      public Time(int year, int month, int day, int hour, int min, int sec)
      Constructor converting a given date into ticks
      Parameters:
      year - the year (counting starts at zero)
      month - the month (between 0 and 12, counting starts at zero)
      day - the day (between 0 and 30, counting starts at zero)
      hour - the hour (between 0 and 24)
      min - the minute (between 0 and 60)
      sec - the second (between 0 and 60)
    • Time

      public Time(int day, int hour, int min)
      Constructor converting a given date into ticks, facilitating shorter time spans.
      Parameters:
      day - the day (counting starts at zero)
      hour - the hour (between 0 and 24)
      min - the minute (between 0 and 60)
  • Method Details

    • getTicks

      public long getTicks()
    • add

      public Time add(long value)
    • add

      public Time add(Time time)
    • sub

      public Time sub(long value)
    • sub

      public Time sub(Time time)
    • isBefore

      public boolean isBefore(Time other)
    • isAfter

      public boolean isAfter(Time other)
    • minutes

      public static long minutes(int minutes)
    • hours

      public static long hours(int hours)
    • days

      public static long days(int days)
    • months

      public static long months(int months)
    • years

      public static long years(int years)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(Time other)
      Specified by:
      compareTo in interface Comparable<Time>