public class LocalDateTimeUtils extends Object
| Constructor and Description |
|---|
LocalDateTimeUtils() |
| Modifier and Type | Method and Description |
|---|---|
static int |
comparePeriods(Period period1,
Period period2)
Compares two periods, assuming 30 days per month.
|
static int |
comparePeriods(Period period1,
Period period2,
int nDaysPerMonth)
Compares two periods, with the assumed number of days per month.
|
static List<LocalDateTimeInterval> |
fixedSizeIntervals(LocalDateTime start,
LocalDateTime end,
Period period)
Creates a list of intervals between
start and end every
so often. |
static boolean |
isWeekend(LocalDateTime time)
Checks if the given time is a weekend.
|
static LocalDateTime |
max(LocalDateTime t1,
LocalDateTime t2)
Returns the later of the two given time instances, or the first
instance if two instances are equal.
|
static LocalDateTime |
min(LocalDateTime t1,
LocalDateTime t2)
Returns the earlier of the two given time instances, or the first
instance if two instances are equal.
|
static LocalDateTime |
nextWeekDay(LocalDateTime time)
Gets the next weekday, i.e., skipping Saturdays and Sundays.
|
static long |
periodCountBetween(LocalDateTime t1,
LocalDateTime t2,
Period period)
Returns the number of whole periods between two time instants.
|
static long |
periodDayCount(Period period,
int nDaysPerMonth)
Estimates the number of days in a period, with the assumed number of days
per month.
|
static List<LocalDateTime> |
periodicInstants(LocalDateTime startTime,
Period period,
int nPeriods)
Generates a list of periodic time instants.
|
static List<LocalDateTime> |
periodicInstantsSpanningInterval(LocalDateTimeInterval interval,
Period period)
Generates a list of periodic time instants which span the whole given
interval.
|
static List<LocalDateTime> |
periodicInstantsWithinInterval(LocalDateTimeInterval interval,
Period period)
Generates a list of periodic time instants within a given interval.
|
static LocalDateTime |
previousWeekDay(LocalDateTime time)
Gets the previous weekday, i.e., skipping Saturdays and Sundays.
|
public static LocalDateTime min(LocalDateTime t1, LocalDateTime t2)
t1 - the first time instancet2 - the second time instancepublic static LocalDateTime max(LocalDateTime t1, LocalDateTime t2)
t1 - the first time instancet2 - the second time instancepublic static boolean isWeekend(LocalDateTime time)
time - a timetrue if the given time is a weekendpublic static LocalDateTime nextWeekDay(LocalDateTime time)
time - a LocalDateTimepublic static LocalDateTime previousWeekDay(LocalDateTime time)
time - a LocalDateTimepublic static List<LocalDateTime> periodicInstants(LocalDateTime startTime, Period period, int nPeriods)
startTime - the start timeperiod - the periodnPeriods - the number of periodspublic static List<LocalDateTime> periodicInstantsWithinInterval(LocalDateTimeInterval interval, Period period)
interval - the intervalperiod - the periodpublic static List<LocalDateTime> periodicInstantsSpanningInterval(LocalDateTimeInterval interval, Period period)
interval - the intervalperiod - the periodpublic static long periodCountBetween(LocalDateTime t1, LocalDateTime t2, Period period)
t1 - the first instantt2 - the second instantperiod - a periodpublic static int comparePeriods(Period period1, Period period2)
period1 - the first periodperiod2 - the second periodpublic static int comparePeriods(Period period1, Period period2, int nDaysPerMonth)
period1 - the first periodperiod2 - the second periodnDaysPerMonth - the assumed number of days per monthpublic static long periodDayCount(Period period, int nDaysPerMonth)
period - the periodnDaysPerMonth - the assumed number of days per monthpublic static List<LocalDateTimeInterval> fixedSizeIntervals(LocalDateTime start, LocalDateTime end, Period period)
start and end every
so often. Note that the last interval ends at the given end time, so it
can be shorter than the given period.start - the start timeend - the end timeperiod - the period or length of each intervalCopyright © 2010-2026 NM Group. All Rights Reserved.