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 TypeMethodDescriptionint
compareTo
(DateTimeValue other) boolean
static DateTimeValue
Makes an instance of date/time value from aTimestamp
.static DateTimeValue
from
(LocalDateTime localDateTime) Makes an instance of date/time value from aLocalDateTime
.static DateTimeValue
Makes an instance of date/time value from aCalendar
.getDate()
Returns the date.getTime()
Returns the time.int
hashCode()
boolean
isAfter
(DateTimeValue dateTime) Returns if this date/time value is after the date/time value in parameter.boolean
isBefore
(DateTimeValue dateTime) Returns if this date/time value is before the date/time value in parameter.boolean
Returns 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 DateTimeValue
now()
Makes an instance of the date/time value corresponding to now.static DateTimeValue
Makes an instance of date/time value from a date with time at 00:00AM.static DateTimeValue
Makes an instance of date/time value from a date and a time.static DateTimeValue
Makes an instance of date/time value from aString
inyyyy-mm-dd
,yyyy-mm-ddThh:mm
,yyyy-mm-ddThh:mm:ss
oryyyy-mm-ddThh:mm:ss.nnnnnnnnn
format.reverse()
Returns the reverse of the date/time.toString()
-
Constructor Details
-
DateTimeValue
Constructor.- Parameters:
date
- The date.time
- The time.- Throws:
NullPointerException
- Ifdate
ortime
isnull
.
-
DateTimeValue
Constructor.- Parameters:
dateTime
- Time inString
format (yyyy-mm-dd
,yyyy-mm-ddThh:mm
,yyyy-mm-ddThh:mm:ss
oryyyy-mm-ddThh:mm:ss.nnnnnnnnn
).- Throws:
NullPointerException
- IfdateTime
isnull
.ParseException
- Ifdate
don't respect theyyyy-mm-dd
,yyyy-mm-ddThh:mm
,yyyy-mm-ddThh:mm:ss
oryyyy-mm-ddThh:mm:ss.nnnnnnnnn
format.
-
DateTimeValue
Constructor.- Parameters:
timestamp
- Timestamp.- Throws:
NullPointerException
- IfdateTime
isnull
.
-
DateTimeValue
Constructor.- Parameters:
calendar
- Calendar.- Throws:
NullPointerException
- Ifcalendar
isnull
.
-
DateTimeValue
Constructor.- Parameters:
localDateTime
- LocalDateTime.- Throws:
NullPointerException
- IflocalDateTime
isnull
.- 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 aString
inyyyy-mm-dd
,yyyy-mm-ddThh:mm
,yyyy-mm-ddThh:mm:ss
oryyyy-mm-ddThh:mm:ss.nnnnnnnnn
format.- Parameters:
dateTime
- Date/time inString
format (yyyy-mm-dd
).- Returns:
- An instance of date/time value.
- Throws:
NullPointerException
- IfdateTime
isnull
.ParseException
- Ifdate
don't respect theyyyy-mm-dd
,yyyy-mm-ddThh:mm
,yyyy-mm-ddThh:mm:ss
oryyyy-mm-ddThh:mm:ss.nnnnnnnnn
format.
-
from
Makes an instance of date/time value from aTimestamp
.- Parameters:
timestamp
- Timestamp.- Returns:
- An instance of date/time value.
- Throws:
NullPointerException
- Iftimestamp
isnull
.
-
from
Makes an instance of date/time value from aCalendar
.- Parameters:
calendar
- Calendar.- Returns:
- An instance of date/time value.
- Throws:
NullPointerException
- Ifcalendar
isnull
.- 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
- IflocalDateTime
isnull
.- 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:
getDate
in interfaceDateValueContainer
- Returns:
- The date.
-
isMidnight
public boolean isMidnight()Description copied from interface:DateValueContainer
Returns if it is midnight.- Specified by:
isMidnight
in interfaceDateValueContainer
- Returns:
true
if it is midnight.
-
getTime
Returns the time.- Returns:
- The time.
-
toString
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareTo
in 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.
-