public class DateValue extends Object implements Comparable<DateValue>, DateValueContainer
Modifier and Type | Field and Description |
---|---|
static String |
DATE_SHOULD_BE_NOT_NULL |
Constructor and Description |
---|
DateValue(Calendar calendar)
Constructor.
|
DateValue(Date date)
Constructor.
|
DateValue(int year,
int month,
int dayOfTheMonth)
Constructor.
|
DateValue(LocalDate localDate)
Constructor.
|
DateValue(String date)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(DateValue other) |
boolean |
equals(Object obj) |
static DateValue |
from(Calendar calendar)
Makes an instance of date value from a
Calendar . |
static DateValue |
from(Date date)
Makes an instance of date value from a
Date . |
static DateValue |
from(LocalDate localDate)
Makes an instance of date value from a
LocalDate . |
DateValue |
getDate()
Returns the date.
|
int |
getDayOfTheMonth()
Returns the day of the month.
|
int |
getMonth()
Returns the month.
|
int |
getYear()
Returns the year.
|
int |
hashCode() |
boolean |
isAfter(DateValue date)
Returns if this date value is after the date value in parameter.
|
boolean |
isBefore(DateValue date)
Returns if this date value is before the date value in parameter.
|
boolean |
isMidnight()
Returns if it is midnight.
|
DateTimeValue |
move(DateTimeValue dateTime)
Moves the date with the value in parameter.
|
DateValue |
move(DateValue date)
Moves the date with the value in parameter.
|
DateTimeValue |
move(TimeValue time)
Moves the date with the value in parameter.
|
static DateValue |
now()
Makes an instance of the date value corresponding to now.
|
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.
|
static DateValue |
parse(String date)
Makes an instance of date value from a
String in format yyyy-mm-dd . |
DateValue |
reverse()
Returns the reverse of the date.
|
String |
toString() |
public static final String DATE_SHOULD_BE_NOT_NULL
public DateValue(int year, int month, int dayOfTheMonth)
year
- Year.month
- Month.dayOfTheMonth
- Day of the month.public DateValue(String date) throws ParseException
date
- Date in String
format (yyyy-mm-dd
).NullPointerException
- If date
is null
.ParseException
- If date
don't respect the yyyy-mm-dd
format.public DateValue(Date date)
date
- Date.NullPointerException
- If date
is null
.public DateValue(Calendar calendar)
calendar
- Calendar.NullPointerException
- If calendar
is null
.public DateValue(LocalDate localDate)
localDate
- LocalDate.NullPointerException
- If localDate
is null
.public static DateValue of(int year, int month, int dayOfTheMonth)
year
- Year.month
- Month.dayOfTheMonth
- Day of the month.public static DateValue parse(String date) throws ParseException
String
in format yyyy-mm-dd
.date
- Date in String
format (yyyy-mm-dd
).NullPointerException
- If date
is null
.ParseException
- If date
don't respect the yyyy-mm-dd
format.public static DateValue from(Date date)
Date
.date
- Date.NullPointerException
- If date
is null
.public static DateValue from(Calendar calendar)
Calendar
.calendar
- Calendar.NullPointerException
- If calendar
is null
.public static DateValue from(LocalDate localDate)
LocalDate
.localDate
- LocalDate.NullPointerException
- If localDate
is null
.public static DateValue now()
public DateValue getDate()
getDate
in interface DateValueContainer
public boolean isMidnight()
DateValueContainer
isMidnight
in interface DateValueContainer
true
if it is midnight.public int getDayOfTheMonth()
public int getMonth()
public int getYear()
public int compareTo(DateValue other)
compareTo
in interface Comparable<DateValue>
public boolean isBefore(DateValue date)
date
- The date value to compare to.public boolean isAfter(DateValue date)
date
- The date value to compare to.public DateValue move(DateValue date)
date
- Value to move the date.public DateTimeValue move(TimeValue time)
time
- Value to move the date.public DateTimeValue move(DateTimeValue dateTime)
dateTime
- Value to move the date.public DateValue reverse()
Copyright © 2020 AssertJ. All rights reserved.