public class VirtualGrid extends Object
DateControl.setVirtualGrid(VirtualGrid)
Modifier and Type | Field and Description |
---|---|
static VirtualGrid |
OFF
The virtual grid in
DateControl can never be null, hence we need
a virtual grid that does nothing, the OFF grid. |
Constructor and Description |
---|
VirtualGrid(String name,
String shortName,
ChronoUnit unit,
int amount)
Constructs a new virtual grid.
|
Modifier and Type | Method and Description |
---|---|
Instant |
adjustTime(Instant instant,
ZoneId zoneId,
boolean roundUp,
DayOfWeek firstDayOfWeek)
Adjusts the given instant either rounding it up or down.
|
LocalDateTime |
adjustTime(LocalDateTime time,
boolean roundUp,
DayOfWeek firstDayOfWeek)
Adjusts the given time either rounding it up or down.
|
ZonedDateTime |
adjustTime(ZonedDateTime time,
boolean roundUp,
DayOfWeek firstDayOfWeek)
Adjusts the given time either rounding it up or down.
|
int |
getAmount()
The number of units used for the grid.
|
String |
getName()
Returns the grid name that can be used for grid selection controls.
|
String |
getShortName()
Returns the grid short name that can be used for grid selection controls.
|
ChronoUnit |
getUnit()
The temporal unit used for the grid.
|
String |
toString() |
public static final VirtualGrid OFF
DateControl
can never be null, hence we need
a virtual grid that does nothing, the OFF grid.DateControl.setVirtualGrid(VirtualGrid)
public VirtualGrid(String name, String shortName, ChronoUnit unit, int amount)
name
- the name of the grid (e.g. "15 Minutes")shortName
- the short name of the grid (e.g. "15 Min.")unit
- the time unit of the grid (seconds, minutes, hours)amount
- the amount of the unit (5, 10, 15 minutes)public final String getName()
public final String getShortName()
public final ChronoUnit getUnit()
public final int getAmount()
public ZonedDateTime adjustTime(ZonedDateTime time, boolean roundUp, DayOfWeek firstDayOfWeek)
time
- the time to adjustroundUp
- the rounding directionfirstDayOfWeek
- the first day of the week (needed for rounding weeks)public Instant adjustTime(Instant instant, ZoneId zoneId, boolean roundUp, DayOfWeek firstDayOfWeek)
instant
- the instant to adjustzoneId
- the time zoneroundUp
- the rounding directionfirstDayOfWeek
- the first day of the week (needed for rounding weeks)public LocalDateTime adjustTime(LocalDateTime time, boolean roundUp, DayOfWeek firstDayOfWeek)
time
- the time to adjustroundUp
- the rounding directionfirstDayOfWeek
- the first day of the week (needed for rounding weeks)Copyright © 2017 Dirk Lemmermann Software & Consulting. All rights reserved.