Package org.assertj.db.type
Class DateTimeValue
java.lang.Object
org.assertj.db.type.DateTimeValue
- All Implemented Interfaces:
Comparable<DateTimeValue>,DateValueContainer
This class represents a date/time value in the database.
- Author:
- Régis Pouiller
-
Constructor Summary
ConstructorsConstructorDescriptionDateTimeValue(String dateTime) Constructor.DateTimeValue(Timestamp timestamp) Constructor.DateTimeValue(LocalDateTime localDateTime) Constructor.DateTimeValue(Calendar calendar) Constructor.DateTimeValue(DateValue date, TimeValue time) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(DateTimeValue other) booleanstatic DateTimeValueMakes an instance of date/time value from aTimestamp.static DateTimeValuefrom(LocalDateTime localDateTime) Makes an instance of date/time value from aLocalDateTime.static DateTimeValueMakes an instance of date/time value from aCalendar.getDate()Returns the date.getTime()Returns the time.inthashCode()booleanisAfter(DateTimeValue dateTime) Returns if this date/time value is after the date/time value in parameter.booleanisBefore(DateTimeValue dateTime) Returns if this date/time value is before the date/time value in parameter.booleanReturns if it is midnight.move(DateTimeValue dateTime) Moves the date/time with the value in parameter.Moves the date/time with the value in parameter.Moves the date/time with the value in parameter.static DateTimeValuenow()Makes an instance of the date/time value corresponding to now.static DateTimeValueMakes an instance of date/time value from a date with time at 00:00AM.static DateTimeValueMakes an instance of date/time value from a date and a time.static DateTimeValueMakes an instance of date/time value from aStringinyyyy-mm-dd,yyyy-mm-ddThh:mm,yyyy-mm-ddThh:mm:ssoryyyy-mm-ddThh:mm:ss.nnnnnnnnnformat.reverse()Returns the reverse of the date/time.toString()
-
Constructor Details
-
DateTimeValue
Constructor.- Parameters:
date- The date.time- The time.- Throws:
NullPointerException- Ifdateortimeisnull.
-
DateTimeValue
Constructor.- Parameters:
dateTime- Time inStringformat (yyyy-mm-dd,yyyy-mm-ddThh:mm,yyyy-mm-ddThh:mm:ssoryyyy-mm-ddThh:mm:ss.nnnnnnnnn).- Throws:
NullPointerException- IfdateTimeisnull.ParseException- Ifdatedon't respect theyyyy-mm-dd,yyyy-mm-ddThh:mm,yyyy-mm-ddThh:mm:ssoryyyy-mm-ddThh:mm:ss.nnnnnnnnnformat.
-
DateTimeValue
Constructor.- Parameters:
timestamp- Timestamp.- Throws:
NullPointerException- IfdateTimeisnull.
-
DateTimeValue
Constructor.- Parameters:
calendar- Calendar.- Throws:
NullPointerException- Ifcalendarisnull.
-
DateTimeValue
Constructor.- Parameters:
localDateTime- LocalDateTime.- Throws:
NullPointerException- IflocalDateTimeisnull.- Since:
- 2.0.0
-
-
Method Details
-
of
Makes an instance of date/time value from a date with time at 00:00AM.- Parameters:
date- The date.- Returns:
- An instance of date/time.
-
of
Makes an instance of date/time value from a date and a time.- Parameters:
date- The date.time- The time.- Returns:
- An instance of date/time.
-
parse
Makes an instance of date/time value from aStringinyyyy-mm-dd,yyyy-mm-ddThh:mm,yyyy-mm-ddThh:mm:ssoryyyy-mm-ddThh:mm:ss.nnnnnnnnnformat.- Parameters:
dateTime- Date/time inStringformat (yyyy-mm-dd).- Returns:
- An instance of date/time value.
- Throws:
NullPointerException- IfdateTimeisnull.ParseException- Ifdatedon't respect theyyyy-mm-dd,yyyy-mm-ddThh:mm,yyyy-mm-ddThh:mm:ssoryyyy-mm-ddThh:mm:ss.nnnnnnnnnformat.
-
from
Makes an instance of date/time value from aTimestamp.- Parameters:
timestamp- Timestamp.- Returns:
- An instance of date/time value.
- Throws:
NullPointerException- Iftimestampisnull.
-
from
Makes an instance of date/time value from aCalendar.- Parameters:
calendar- Calendar.- Returns:
- An instance of date/time value.
- Throws:
NullPointerException- Ifcalendarisnull.- Since:
- 1.1.0
-
from
Makes an instance of date/time value from aLocalDateTime.- Parameters:
localDateTime- LocalDateTime.- Returns:
- An instance of date/time value.
- Throws:
NullPointerException- IflocalDateTimeisnull.- Since:
- 2.0.0
-
now
Makes an instance of the date/time value corresponding to now.- Returns:
- An instance of date/time 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.
-
getTime
Returns the time.- Returns:
- The time.
-
toString
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<DateTimeValue>
-
isBefore
Returns if this date/time value is before the date/time value in parameter.- Parameters:
dateTime- The date/time value to compare to.- Returns:
- If this date/time value is before the date/time value in parameter.
-
isAfter
Returns if this date/time value is after the date/time value in parameter.- Parameters:
dateTime- The date/time value to compare to.- Returns:
- If this date/time value is after the date/time value in parameter.
-
move
Moves the date/time with the value in parameter.- Parameters:
date- Value to move the date.- Returns:
- The date/time moved.
-
move
Moves the date/time with the value in parameter.- Parameters:
time- Value to move the date.- Returns:
- The date/time moved.
-
move
Moves the date/time with the value in parameter.- Parameters:
dateTime- Value to move the date.- Returns:
- The date/time moved.
-
reverse
Returns the reverse of the date/time.- Returns:
- The reverse.
-