public abstract class StartOfDay extends Object
Defines the start of a given calendar day relative to midnight in seconds.
| Modifier and Type | Field and Description |
|---|---|
static StartOfDay |
EVENING
Start of calendar day at 18:00 on previous day.
|
static StartOfDay |
MIDNIGHT
Default start of calendar day at midnight.
|
static StartOfDay |
MORNING
Start of calendar day at 06:00 in the morning.
|
| Modifier and Type | Method and Description |
|---|---|
static <T extends UnixTime> |
definedBy(ChronoFunction<CalendarDate,Optional<T>> event)
Obtains the start of a calendar day as determined by given date function.
|
abstract int |
getDeviation(Calendrical<?,?> calendarDay,
TZID tzid)
Deprecated.
The signature will be changed in next major release such
that the type
CalendarDate will be used instead of Calendrical |
static StartOfDay |
ofFixedDeviation(int deviation)
Obtains the start of a calendar day relative to midnight in fixed seconds.
|
public static final StartOfDay MIDNIGHT
public static final StartOfDay EVENING
public static final StartOfDay MORNING
public static StartOfDay ofFixedDeviation(int deviation)
Obtains the start of a calendar day relative to midnight in fixed seconds.
A negative deviation is explicitly allowed and refers to the previous calendar day.
deviation - the deviation of start of day relative to midnight in seconds on the local timelineIllegalArgumentException - if the argument is out of range -43200 < deviation <= 43200public static <T extends UnixTime> StartOfDay definedBy(ChronoFunction<CalendarDate,Optional<T>> event)
Obtains the start of a calendar day as determined by given date function.
If the given function cannot determine a moment for a calendar day then an exception will be thrown. This method is most suitable for calendars whose days start on astronomical events like sunset. Example:
HijriCalendar hijri = HijriCalendar.ofUmalqura(1436, 10, 2);
SolarTime mekkaTime = SolarTime.ofLocation(21.4225, 39.826111);
ZonalOffset saudiArabia = ZonalOffset.ofHours(OffsetSign.AHEAD_OF_UTC, 3);
StartOfDay startOfDay = StartOfDay.definedBy(mekkaTime.sunset());
// short after sunset (2015-07-17T19:05:40)
System.out.println(
hijri.atTime(19, 6).at(saudiArabia, startOfDay)); // 2015-07-17T19:06+03:00
// short before sunset (2015-07-17T19:05:40)
System.out.println(
hijri.minus(CalendarDays.ONE).atTime(19, 5).at(saudiArabia, startOfDay)); // 2015-07-17T19:05+03:00
T - generic type parameter indicating the time of the eventevent - function which yields the relevant moment for a given calendar day@Deprecated public abstract int getDeviation(Calendrical<?,?> calendarDay, TZID tzid)
CalendarDate will be used instead of CalendricalYields the start of given calendar day relative to midnight in seconds.
calendarDay - calendar daytzid - timezone identifier, helps to resolve an UTC-event like sunset to a local timeCopyright © 2014–2017. All rights reserved.