Class WorkCalendar
java.lang.Object
com.codename1.scheduling.WorkCalendar
The hours work happens in: a weekly pattern, and the days that differ from it.
A duration in a project is working time. Two days of work that start on a
Friday afternoon end on Tuesday, and this is the class that says so. A
Scheduler reads the same object to shade the hours nobody works.
The default is Monday to Friday, 09:00 to 17:00, in the device's zone.
-
Constructor Summary
ConstructorsConstructorDescriptionA Monday to Friday, 09:00 to 17:00 calendar in the device's zone.WorkCalendar(ZoneId zone) A Monday to Friday, 09:00 to 17:00 calendar inzone. -
Method Summary
Modifier and TypeMethodDescriptionaddHoliday(long epochDay) Makes one date a day off, whatever the week says.longaddWorkingTime(long from, long duration) The instantdurationmilliseconds of working time afterfrom.static WorkCalendarcontinuous(ZoneId zone) A calendar in which every minute of every day is working time, for durations that are elapsed time.longThe working time in a full day of the weekly pattern, which is what "a day" of duration means in this calendar.int[]getWorkingHours(long epochDay) The working hours of a date, as pairs of minutes since midnight.getZone()booleanisWorkingDay(long epochDay) booleanisWorkingTime(long millis) Whethermillisis inside working hours.booleanisWorkingWeekday(int isoDay) longnextWorkingTime(long millis) The first working instant at or aftermillis.longpreviousWorkingTime(long millis) The last instant at or beforemillisthat work can end at:millisitself when it is inside working hours or closes them.removeException(long epochDay) Returns a date to the weekly pattern.setException(long epochDay, int... startEndMinutes) Gives one date hours of its own, whatever the week says.setWorkingDay(int isoDay, boolean working) Whether a day of the week is worked.setWorkingHours(int... startEndMinutes) The hours of every working day that has none of its own, as pairs of minutes since midnight:setWorkingHours(8 * 60, 12 * 60, 13 * 60, 17 * 60)is a day with a lunch break.setWorkingHours(int isoDay, int[] startEndMinutes) The hours of one day of the week, which also makes it a working day.longsubtractWorkingTime(long from, long duration) The instantdurationmilliseconds of working time beforefrom.longworkingTimeBetween(long from, long to) The working time between two instants, negative whentois beforefrom.
-
Constructor Details
-
WorkCalendar
public WorkCalendar()A Monday to Friday, 09:00 to 17:00 calendar in the device's zone. -
WorkCalendar
A Monday to Friday, 09:00 to 17:00 calendar inzone.
-
-
Method Details
-
continuous
A calendar in which every minute of every day is working time, for durations that are elapsed time. -
getZone
-
setWorkingDay
Whether a day of the week is worked.isoDayis 1 for Monday to 7 for Sunday. -
isWorkingWeekday
public boolean isWorkingWeekday(int isoDay) -
setWorkingHours
The hours of every working day that has none of its own, as pairs of minutes since midnight:setWorkingHours(8 * 60, 12 * 60, 13 * 60, 17 * 60)is a day with a lunch break. An end of1440is midnight. -
setWorkingHours
The hours of one day of the week, which also makes it a working day. -
addHoliday
Makes one date a day off, whatever the week says. -
setException
Gives one date hours of its own, whatever the week says. -
removeException
Returns a date to the weekly pattern. -
getWorkingHours
public int[] getWorkingHours(long epochDay) The working hours of a date, as pairs of minutes since midnight. Empty for a day off. The array is the calendar's own: read it, do not change it. -
isWorkingDay
public boolean isWorkingDay(long epochDay) -
isWorkingTime
public boolean isWorkingTime(long millis) Whethermillisis inside working hours. -
nextWorkingTime
public long nextWorkingTime(long millis) The first working instant at or aftermillis. -
previousWorkingTime
public long previousWorkingTime(long millis) The last instant at or beforemillisthat work can end at:millisitself when it is inside working hours or closes them. -
addWorkingTime
public long addWorkingTime(long from, long duration) The instantdurationmilliseconds of working time afterfrom. A duration that ends exactly as a working period closes ends there, not at the opening of the next one. A negative duration goes backwards. -
subtractWorkingTime
public long subtractWorkingTime(long from, long duration) The instantdurationmilliseconds of working time beforefrom. -
workingTimeBetween
public long workingTimeBetween(long from, long to) The working time between two instants, negative whentois beforefrom. -
getMillisPerDay
public long getMillisPerDay()The working time in a full day of the weekly pattern, which is what "a day" of duration means in this calendar.
-