Class DateValue

java.lang.Object
org.assertj.db.type.DateValue
All Implemented Interfaces:
Comparable<DateValue>, DateValueContainer

public class DateValue extends Object implements Comparable<DateValue>, DateValueContainer
This class represents a date value in the database.
Author:
Régis Pouiller
  • Constructor Details

    • DateValue

      public DateValue(int year, int month, int dayOfTheMonth)
      Constructor.
      Parameters:
      year - Year.
      month - Month.
      dayOfTheMonth - Day of the month.
    • DateValue

      public DateValue(String date) throws ParseException
      Constructor.
      Parameters:
      date - Date in String format (yyyy-mm-dd).
      Throws:
      NullPointerException - If date is null.
      ParseException - If date don't respect the yyyy-mm-dd format.
    • DateValue

      public DateValue(Date date)
      Constructor.
      Parameters:
      date - Date.
      Throws:
      NullPointerException - If date is null.
    • DateValue

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

      public DateValue(LocalDate localDate)
      Constructor.
      Parameters:
      localDate - LocalDate.
      Throws:
      NullPointerException - If localDate is null.
      Since:
      2.0.0
  • Method Details

    • of

      public static DateValue of(int year, int month, int dayOfTheMonth)
      Makes an instance of date value from a day of month, a month and an year.
      Parameters:
      year - Year.
      month - Month.
      dayOfTheMonth - Day of the month.
      Returns:
      An instance of date value.
    • parse

      public static DateValue parse(String date) throws ParseException
      Makes an instance of date value from a String in format yyyy-mm-dd.
      Parameters:
      date - Date in String format (yyyy-mm-dd).
      Returns:
      An instance of date value.
      Throws:
      NullPointerException - If date is null.
      ParseException - If date don't respect the yyyy-mm-dd format.
    • from

      public static DateValue from(Date date)
      Makes an instance of date value from a Date.
      Parameters:
      date - Date.
      Returns:
      An instance of date value.
      Throws:
      NullPointerException - If date is null.
    • from

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

      public static DateValue from(LocalDate localDate)
      Makes an instance of date value from a LocalDate.
      Parameters:
      localDate - LocalDate.
      Returns:
      An instance of date value.
      Throws:
      NullPointerException - If localDate is null.
      Since:
      2.0.0
    • now

      public static DateValue now()
      Makes an instance of the date value corresponding to now.
      Returns:
      An instance of date value.
      Since:
      1.1.0
    • getDate

      public DateValue getDate()
      Returns the date.
      Specified by:
      getDate in interface DateValueContainer
      Returns:
      The date.
    • isMidnight

      public boolean isMidnight()
      Description copied from interface: DateValueContainer
      Returns if it is midnight.
      Specified by:
      isMidnight in interface DateValueContainer
      Returns:
      true if it is midnight.
    • getDayOfTheMonth

      public int getDayOfTheMonth()
      Returns the day of the month.
      Returns:
      The day of the month.
    • getMonth

      public int getMonth()
      Returns the month.
      Returns:
      The month.
    • getYear

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

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

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

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

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

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

      public DateValue reverse()
      Returns the reverse of the date.
      Returns:
      The reverse.