Package org.assertj.db.type
Class DateValue
java.lang.Object
org.assertj.db.type.DateValue
- All Implemented Interfaces:
Comparable<DateValue>,DateValueContainer
This class represents a date value in the database.
- Author:
- Régis Pouiller
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbooleanstatic DateValueMakes an instance of date value from aDate.static DateValueMakes an instance of date value from aLocalDate.static DateValueMakes an instance of date value from aCalendar.getDate()Returns the date.intReturns the day of the month.intgetMonth()Returns the month.intgetYear()Returns the year.inthashCode()booleanReturns if this date value is after the date value in parameter.booleanReturns if this date value is before the date value in parameter.booleanReturns if it is midnight.move(DateTimeValue dateTime) Moves the date with the value in parameter.Moves the date with the value in parameter.Moves the date with the value in parameter.static DateValuenow()Makes an instance of the date value corresponding to now.static DateValueof(int year, int month, int dayOfTheMonth) Makes an instance of date value from a day of month, a month and an year.static DateValueMakes an instance of date value from aStringin formatyyyy-mm-dd.reverse()Returns the reverse of the date.toString()
-
Constructor Details
-
DateValue
public DateValue(int year, int month, int dayOfTheMonth) Constructor.- Parameters:
year- Year.month- Month.dayOfTheMonth- Day of the month.
-
DateValue
Constructor.- Parameters:
date- Date inStringformat (yyyy-mm-dd).- Throws:
NullPointerException- Ifdateisnull.ParseException- Ifdatedon't respect theyyyy-mm-ddformat.
-
DateValue
Constructor.- Parameters:
date- Date.- Throws:
NullPointerException- Ifdateisnull.
-
DateValue
Constructor.- Parameters:
calendar- Calendar.- Throws:
NullPointerException- Ifcalendarisnull.
-
DateValue
Constructor.- Parameters:
localDate- LocalDate.- Throws:
NullPointerException- IflocalDateisnull.- Since:
- 2.0.0
-
-
Method Details
-
of
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
Makes an instance of date value from aStringin formatyyyy-mm-dd.- Parameters:
date- Date inStringformat (yyyy-mm-dd).- Returns:
- An instance of date value.
- Throws:
NullPointerException- Ifdateisnull.ParseException- Ifdatedon't respect theyyyy-mm-ddformat.
-
from
Makes an instance of date value from aDate.- Parameters:
date- Date.- Returns:
- An instance of date value.
- Throws:
NullPointerException- Ifdateisnull.
-
from
Makes an instance of date value from aCalendar.- Parameters:
calendar- Calendar.- Returns:
- An instance of date value.
- Throws:
NullPointerException- Ifcalendarisnull.- Since:
- 1.1.0
-
from
Makes an instance of date value from aLocalDate.- Parameters:
localDate- LocalDate.- Returns:
- An instance of date value.
- Throws:
NullPointerException- IflocalDateisnull.- Since:
- 2.0.0
-
now
Makes an instance of the date value corresponding to now.- Returns:
- An instance of date value.
- Since:
- 1.1.0
-
getDate
Returns the date.- Specified by:
getDatein interfaceDateValueContainer- Returns:
- The date.
-
isMidnight
public boolean isMidnight()Description copied from interface:DateValueContainerReturns if it is midnight.- Specified by:
isMidnightin interfaceDateValueContainer- Returns:
trueif 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
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<DateValue>
-
isBefore
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
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
Moves the date with the value in parameter.- Parameters:
date- Value to move the date.- Returns:
- The date moved.
-
move
Moves the date with the value in parameter.- Parameters:
time- Value to move the date.- Returns:
- The date/time moved.
-
move
Moves the date with the value in parameter.- Parameters:
dateTime- Value to move the date.- Returns:
- The date/time moved.
-
reverse
Returns the reverse of the date.- Returns:
- The reverse.
-