Class DateUtil
java.lang.Object
ch.tocco.nice2.optional.timereport.impl.util.DateUtil
class providing static utilities for Date
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
getDaysDifference
(org.joda.time.LocalDate reference, org.joda.time.LocalDate other) static org.joda.time.LocalDate
getFirstDayInYear
(int year) static org.joda.time.LocalDate
getLastDayInYear
(int year) static boolean
intersect
(org.joda.time.LocalDate from1, @Nullable org.joda.time.LocalDate until1, org.joda.time.LocalDate from2, @Nullable org.joda.time.LocalDate until2) static boolean
isInDaysPeriod
(org.joda.time.LocalDate date, org.joda.time.LocalDate start, @Nullable org.joda.time.LocalDate end) static org.joda.time.LocalDate
max
(org.joda.time.LocalDate... dates) static org.joda.time.LocalDate
min
(org.joda.time.LocalDate... dates) static Duration
roundToMinutes
(Duration duration) Round a duration to the nearest minutes.
-
Method Details
-
max
public static org.joda.time.LocalDate max(org.joda.time.LocalDate... dates) - Parameters:
dates
- a list of dates @return the largest date from the list- Returns:
- the max date in the list
-
min
public static org.joda.time.LocalDate min(org.joda.time.LocalDate... dates) - Parameters:
dates
- a list of dates- Returns:
- the smallest date from the list
-
getDaysDifference
public static int getDaysDifference(org.joda.time.LocalDate reference, org.joda.time.LocalDate other) - Parameters:
reference
- the reference dateother
- an other date- Returns:
- The difference in days between the two dates. If other > reference the result is > 0.
-
roundToMinutes
Round a duration to the nearest minutes.- Parameters:
duration
- duration to round- Returns:
- a Duration rounded to minues
-
isInDaysPeriod
public static boolean isInDaysPeriod(org.joda.time.LocalDate date, org.joda.time.LocalDate start, @Nullable @Nullable org.joda.time.LocalDate end) - Parameters:
date
- the reference datestart
- the start dateend
- the end date (is considered∞
if null)- Returns:
- true if and only if
reference ∈ [start, end]
-
intersect
public static boolean intersect(org.joda.time.LocalDate from1, @Nullable @Nullable org.joda.time.LocalDate until1, org.joda.time.LocalDate from2, @Nullable @Nullable org.joda.time.LocalDate until2) -
getFirstDayInYear
public static org.joda.time.LocalDate getFirstDayInYear(int year) -
getLastDayInYear
public static org.joda.time.LocalDate getLastDayInYear(int year)
-