public class DateRangeUtil extends Object
Constructor and Description |
---|
DateRangeUtil() |
Modifier and Type | Method and Description |
---|---|
static DateRangePrecision |
getPrecision(Calendar calendar)
Returns the precision of a calendar obtained through
parseCalendar(String) , or null if no field was set. |
static Calendar |
parseCalendar(String source)
Parses the given string as a date in a range bound.
|
static ZonedDateTime |
roundDown(ZonedDateTime date,
ChronoUnit unit)
Sets all the fields smaller than the given unit to their lowest possible value.
|
static ZonedDateTime |
roundUp(ZonedDateTime date,
ChronoUnit unit)
Sets all the fields smaller than the given unit to their highest possible value.
|
static ZonedDateTime |
toZonedDateTime(Calendar calendar) |
@NonNull public static ZonedDateTime roundDown(@NonNull ZonedDateTime date, @NonNull ChronoUnit unit)
@NonNull public static ZonedDateTime roundUp(@NonNull ZonedDateTime date, @NonNull ChronoUnit unit)
public static Calendar parseCalendar(String source) throws ParseException
This method deliberately uses legacy time APIs, in order to be as close as possible to the server-side parsing logic. We want the client to behave exactly like the server, i.e. parsing a date locally and inlining it in a CQL query should always yield the same result as binding the date as a value.
ParseException
@Nullable public static DateRangePrecision getPrecision(Calendar calendar)
parseCalendar(String)
, or null
if no field was set.public static ZonedDateTime toZonedDateTime(Calendar calendar)
Copyright © 2017–2019. All rights reserved.