public final class ChronoUnitResolution extends Resolution<ChronoUnit>
ChronoUnit
that can be used in combination with
the ChronoUnitDatelineModel
.DatelineModel.addResolution(Resolution)
Resolution.Position
Constructor and Description |
---|
ChronoUnitResolution(ChronoUnit unit,
String format,
int stepRate)
Constructs a new resolution for the given unit, format, step rate, and positions.
|
ChronoUnitResolution(ChronoUnit unit,
String format,
int stepRate,
Resolution.Position... supportedPositions)
Constructs a new resolution for the given unit, format, step rate, and positions.
|
Modifier and Type | Method and Description |
---|---|
VirtualGrid<ChronoUnit> |
createGrid()
Creates a virtual grid for editing operations based on the settings of this
resolution.
|
Instant |
decrement(Instant instant,
ZoneId zoneId)
Decrements the given time based on the temporal unit represented by this
resolution.
|
String |
format(Instant instant,
ZoneId zoneId)
Formats the given time / instant for the given time zone based on the
settings of this resolution.
|
Instant |
increment(Instant instant,
ZoneId zoneId)
Increments the given time based on the temporal unit represented by this
resolution.
|
boolean |
isDSTEndIncrement()
Returns true if the last call to
increment(Instant, ZoneId) was affected
by a DST end. |
boolean |
isDSTStartIncrement()
Returns true if the last call to
increment(Instant, ZoneId) was affected
by a DST start. |
Instant |
truncate(Instant instant,
ZoneId zoneId,
DayOfWeek firstDayOfWeek)
Truncates the given time based on the temporal unit represented by this
resolution.
|
getFormat, getStepRate, getTemporalUnit, isSupportingPosition, toString
public ChronoUnitResolution(ChronoUnit unit, String format, int stepRate, Resolution.Position... supportedPositions)
unit
- the chrono unit supported by this resolution (e.g. DAY)format
- the format how the unit will be shown on the screenstepRate
- the step rate (e.g. "1" Minute, "5" Minutes, "15" Minutes)supportedPositions
- the position inside the dateline where this resolution can be displayed (top, middle, bottom)public ChronoUnitResolution(ChronoUnit unit, String format, int stepRate)
unit
- the chrono unit supported by this resolution (e.g. DAY)format
- the format how the unit will be shown on the screenstepRate
- the step rate (e.g. "1" Minute, "5" Minutes, "15" Minutes)public String format(Instant instant, ZoneId zoneId)
Resolution
format
in class Resolution<ChronoUnit>
instant
- the time used for the formattingzoneId
- the time zonepublic Instant truncate(Instant instant, ZoneId zoneId, DayOfWeek firstDayOfWeek)
Resolution
truncate
in class Resolution<ChronoUnit>
instant
- the time to truncatezoneId
- the time zonefirstDayOfWeek
- the weekday that is considered to be the first
day of the weekpublic boolean isDSTStartIncrement()
increment(Instant, ZoneId)
was affected
by a DST start. Example: if the resolution is "3 hours" and the current time is midnight,
then the new local time might actually be 4am, instead of 3am. Because on DST start
the clocks will be advanced by one hour.public boolean isDSTEndIncrement()
increment(Instant, ZoneId)
was affected
by a DST end. Example: if the resolution is "3 hours" and the current time is midnight,
then the new local time might actually be 2am, instead of 3am. Because on DST end
the clocks will be turned back by one hour.public Instant increment(Instant instant, ZoneId zoneId)
Resolution
increment
in class Resolution<ChronoUnit>
instant
- the time to incrementzoneId
- the time zonepublic Instant decrement(Instant instant, ZoneId zoneId)
Resolution
decrement
in class Resolution<ChronoUnit>
instant
- the time to incrementzoneId
- the time zonepublic VirtualGrid<ChronoUnit> createGrid()
Resolution
createGrid
in class Resolution<ChronoUnit>
Copyright © 2020 Dirk Lemmermann Software & Consulting. All rights reserved.