Package rs.baselib.util
Class DateTimeUtils
java.lang.Object
rs.baselib.util.DateTimeUtils
Utils for date and time.
- Author:
- ralph
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ZonedDateTime
getEndOfDay
(ZonedDateTime time) Returns the timestamp at the start of the day (23:59:59.999).static ZonedDateTime
getStartOfDay
(ZonedDateTime time) Returns the timestamp at the start of the day (00:00:00.000).static boolean
isAfter
(ZonedDateTime time, long millisAfter) Returns whether a given time is later than the given duration.static boolean
isAfter
(ZonedDateTime time, TemporalAmount amountAfter) Returns whether a given time is earlier than the given duration.static boolean
isAfter
(ZonedDateTime time, ZonedDateTime other) Returns whether a given time is earlier than the other time.static boolean
isBefore
(ZonedDateTime time, long millisBefore) Returns whether a given time is earlier than the given duration.static boolean
isBefore
(ZonedDateTime time, TemporalAmount amountBefore) Returns whether a given time is earlier than the given duration.static boolean
isBefore
(ZonedDateTime time, ZonedDateTime other) Returns whether a given time is earlier than the given other time.static ZonedDateTime
Tries to parse the string in order to retrieve a date/time with default ZoneId and default time 00:00:00.static ZonedDateTime
parseZonedDateTime
(String s, LocalTime defaultTime) Tries to parse the string in order to retrieve a date/time with default ZoneId and given default time.static ZonedDateTime
parseZonedDateTime
(String s, LocalTime defaultTime, ZoneId defaultZone) Tries to parse the string in order to retrieve a date/time with default ZoneId and given default time and zoneId.static ZonedDateTime
parseZonedDateTime
(String s, ZoneId defaultZone) Tries to parse the string in order to retrieve a date/time default time 00:00:00.static ZonedDateTime
Tries to parse the string in order to retrieve a date/time with default ZoneId and default time 23:59:59.999999999.static ZonedDateTime
parseZonedDateTimeWithEndOfDay
(String s, ZoneId defaultZone) Tries to parse the string in order to retrieve a date/time with default time 23:59:59.999999999.
-
Constructor Details
-
DateTimeUtils
public DateTimeUtils()
-
-
Method Details
-
isBefore
Returns whether a given time is earlier than the given duration.- Parameters:
time
- the time to comparemillisBefore
- ms before now- Returns:
true
when time is before that time span
-
isBefore
Returns whether a given time is earlier than the given duration.- Parameters:
time
- the time to compareamountBefore
- the duration before now- Returns:
true
when time is before that time span
-
isBefore
Returns whether a given time is earlier than the given other time.- Parameters:
time
- the time to compareother
- the other time- Returns:
true
when time is before that other time
-
isAfter
Returns whether a given time is later than the given duration.- Parameters:
time
- the time to comparemillisAfter
- the duration after now- Returns:
true
when time is after that duration from now
-
isAfter
Returns whether a given time is earlier than the given duration.- Parameters:
time
- the time to compareamountAfter
- the duration after now- Returns:
true
when time is after that duration from now
-
isAfter
Returns whether a given time is earlier than the other time.- Parameters:
time
- the time to compareother
- the other time- Returns:
true
when time is after that other time
-
getStartOfDay
Returns the timestamp at the start of the day (00:00:00.000).- Parameters:
time
- time of a day- Returns:
- beginning of that day
-
getEndOfDay
Returns the timestamp at the start of the day (23:59:59.999).- Parameters:
time
- time of a day- Returns:
- end of that day
-
parseZonedDateTime
Tries to parse the string in order to retrieve a date/time with default ZoneId and default time 00:00:00.- Parameters:
s
- - the string to be parsed- Returns:
- the
ZonedDateTime
object ornull
if not successful.
-
parseZonedDateTime
Tries to parse the string in order to retrieve a date/time default time 00:00:00.- Parameters:
s
- - the string to be parseddefaultZone
- - default zone ID to be used- Returns:
- the
ZonedDateTime
object ornull
if not successful.
-
parseZonedDateTimeWithEndOfDay
Tries to parse the string in order to retrieve a date/time with default ZoneId and default time 23:59:59.999999999.- Parameters:
s
- - the string to be parsed- Returns:
- the
ZonedDateTime
object ornull
if not successful.
-
parseZonedDateTimeWithEndOfDay
Tries to parse the string in order to retrieve a date/time with default time 23:59:59.999999999.- Parameters:
s
- - the string to be parseddefaultZone
- - default zone ID to be used- Returns:
- the
ZonedDateTime
object ornull
if not successful.
-
parseZonedDateTime
Tries to parse the string in order to retrieve a date/time with default ZoneId and given default time.- Parameters:
s
- - the string to be parseddefaultTime
- - default time to be used- Returns:
- the
ZonedDateTime
object ornull
if not successful.
-
parseZonedDateTime
Tries to parse the string in order to retrieve a date/time with default ZoneId and given default time and zoneId.- Parameters:
s
- - the string to be parseddefaultTime
- - default time to be useddefaultZone
- - default zone ID to be used- Returns:
- the
ZonedDateTime
object ornull
if not successful.
-