Class TimeValue

java.lang.Object
org.assertj.db.type.TimeValue
All Implemented Interfaces:
Comparable<TimeValue>

public class TimeValue extends Object implements Comparable<TimeValue>
This class represents a time value in the database.
Author:
Régis Pouiller, Julien Roy
  • Constructor Details

    • TimeValue

      public TimeValue(int hours, int minutes, int seconds, int nanoSeconds)
      Constructor.
      Parameters:
      hours - Hours.
      minutes - Minutes.
      seconds - Seconds.
      nanoSeconds - Nanoseconds.
    • TimeValue

      public TimeValue(int hours, int minutes, int seconds)
      Constructor.
      Parameters:
      hours - Hours.
      minutes - Minutes.
      seconds - Seconds.
    • TimeValue

      public TimeValue(int hours, int minutes)
      Constructor.
      Parameters:
      hours - Hours.
      minutes - Minutes.
    • TimeValue

      public TimeValue(String time) throws ParseException
      Constructor.
      Parameters:
      time - Time in String format (hh:mm, hh:mm:ss or hh:mm:ss.nnnnnnnnn).
      Throws:
      NullPointerException - If time is null.
      ParseException - If time don't respect the hh:mm, hh:mm:ss or hh:mm:ss.nnnnnnnnn format.
    • TimeValue

      public TimeValue(Time time)
      Constructor.
      Parameters:
      time - Time.
      Throws:
      NullPointerException - If time is null.
    • TimeValue

      public TimeValue(Calendar calendar)
      Constructor.
      Parameters:
      calendar - Calendar.
      Throws:
      NullPointerException - If calendar is null.
    • TimeValue

      public TimeValue(LocalTime localTime)
      Constructor.
      Parameters:
      localTime - LocalTime.
      Throws:
      NullPointerException - If localTime is null.
      Since:
      2.0.0
  • Method Details

    • of

      public static TimeValue of(int hours, int minutes, int seconds, int nanoSeconds)
      Makes an instance of time value from a hours, minutes, seconds and nanoseconds.
      Parameters:
      hours - Hours.
      minutes - Minutes.
      seconds - Seconds.
      nanoSeconds - Nanoseconds.
      Returns:
      An instance of time value.
    • of

      public static TimeValue of(int hours, int minutes, int seconds)
      Makes an instance of time value from a hours, minutes and seconds.
      Parameters:
      hours - Hours.
      minutes - Minutes.
      seconds - Seconds.
      Returns:
      An instance of time value.
    • of

      public static TimeValue of(int hours, int minutes)
      Makes an instance of time value from a hours and minutes.
      Parameters:
      hours - Hours.
      minutes - Minutes.
      Returns:
      An instance of time value.
    • parse

      public static TimeValue parse(String time) throws ParseException
      Makes an instance of time value from a String in hh:mm, hh:mm:ss or hh:mm:ss.nnnnnnnnn format.
      Parameters:
      time - Time in String format (hh:mm, hh:mm:ss or hh:mm:ss.nnnnnnnnn).
      Returns:
      An instance of time value.
      Throws:
      NullPointerException - If time is null.
      ParseException - If time don't respect the hh:mm, hh:mm:ss or hh:mm:ss.nnnnnnnnn format.
    • from

      public static TimeValue from(Time time)
      Makes an instance of time value from a Time.
      Parameters:
      time - Time.
      Returns:
      An instance of time value.
      Throws:
      NullPointerException - If time is null.
    • from

      public static TimeValue from(Calendar calendar)
      Makes an instance of time value from a Calendar.
      Parameters:
      calendar - Calendar.
      Returns:
      An instance of time value.
      Throws:
      NullPointerException - If calendar is null.
      Since:
      1.1.0
    • from

      public static TimeValue from(LocalTime localTime)
      Makes an instance of time value from a LocalTime.
      Parameters:
      localTime - LocalTime.
      Returns:
      An instance of time value.
      Throws:
      NullPointerException - If localTime is null.
      Since:
      2.0.0
    • now

      public static TimeValue now()
      Makes an instance of the time value corresponding to now.
      Returns:
      An instance of time value.
      Since:
      1.1.0
    • getHours

      public int getHours()
      Returns the hours.
      Returns:
      The hours.
    • getMinutes

      public int getMinutes()
      Returns the minutes.
      Returns:
      The minutes.
    • getSeconds

      public int getSeconds()
      Returns the seconds.
      Returns:
      The seconds.
    • getNanoSeconds

      public int getNanoSeconds()
      Returns the nanoseconds.
      Returns:
      The nanoseconds.
    • 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(TimeValue other)
      Specified by:
      compareTo in interface Comparable<TimeValue>
    • isBefore

      public boolean isBefore(TimeValue time)
      Returns if this time value is before the time value in parameter.
      Parameters:
      time - The time value to compare to.
      Returns:
      If this time value is before the time value in parameter.
    • isAfter

      public boolean isAfter(TimeValue time)
      Returns if this time value is after the time value in parameter.
      Parameters:
      time - The time value to compare to.
      Returns:
      If this time value is after the time value in parameter.
    • move

      public TimeValue move(TimeValue time)
      Moves the time with the value in parameter.
      Parameters:
      time - Value to move the date.
      Returns:
      The date/time moved.
    • reverse

      public TimeValue reverse()
      Returns the reverse of the time.
      Returns:
      The reverse.