public class Dates
extends java.lang.Object
Modifier and Type | Class | Description |
---|---|---|
static class |
Dates.Time |
Constructor | Description |
---|---|
Dates() |
Modifier and Type | Method | Description |
---|---|---|
static java.util.Date |
createDate(java.util.Date datePart,
java.util.Date timePart) |
Build a new Date from two Date-typed parameters, the first one
representing an actual date (yyyy-MM-dd) and a second one representing
the time of of day (hh:mm:ss).
|
static long |
daysBetween(java.util.Date firstDate,
java.util.Date secondDate) |
Return the number of days between two dates.
|
static java.util.Date |
getDate(int numberOfDays,
Dates.Time time) |
Get a relative date (yesterday, last week, etc.) compared to the current
date.
For instance:
Date aMonthAgo = DateHelper.getDate(30, Time.BEFORE); |
static boolean |
isLeapYear(int year) |
|
static java.util.Date |
toDate(java.time.LocalDate localDate) |
Convert a LocalDate into a Date instance.
|
static java.time.LocalDate |
toLocalDate(java.util.Date date) |
Convert a Date into a LocalDate instance.
|
public static java.util.Date createDate(java.util.Date datePart, java.util.Date timePart)
datePart
- a Date object in which time-related fields are ignored.timePart
- a Date object in which date-related fields are ignored. , e.g.
15:36:07 (date-part ignored)public static long daysBetween(java.util.Date firstDate, java.util.Date secondDate)
firstDate
- secondDate
- public static java.util.Date getDate(int numberOfDays, Dates.Time time)
Date aMonthAgo = DateHelper.getDate(30, Time.BEFORE);
Date aWeekAgo = DateHelper.getDate(7, Time.BEFORE);
Date yesterday = DateHelper.getDate(1, Time.BEFORE);
Date tomorrow = DateHelper.getDate(1, Time.AFTER);
numberOfDays
- a positive or negative number of dayspublic static boolean isLeapYear(int year)
public static java.time.LocalDate toLocalDate(java.util.Date date)
date
- to convertpublic static java.util.Date toDate(java.time.LocalDate localDate)
localDate
- to convert