Class TimeMath
java.lang.Object
com.codename1.scheduling.TimeMath
Calendar arithmetic on epoch milliseconds in a time zone.
The scheduling model keeps every instant as epoch milliseconds, because a
view compares and subtracts them for every item it paints. These are the
few places where an instant has to become a calendar day and back, and they
go through java.time so a day that is 23 or 25 hours long is handled by
the zone rules and not by adding 24 * 60 * 60 * 1000.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longMilliseconds in a day that has no zone transition in it.static final longMilliseconds in an hour.static final longMilliseconds in a minute.static final intMinutes in a day. -
Method Summary
Modifier and TypeMethodDescriptionstatic longThe instant of a wall-clock minute on a day.static intdayOfWeek(long epochDay) The ISO day of the week of a day: 1 is Monday, 7 is Sunday.static longThe daymillisfalls on inzone, as a count of days since 1970-01-01.static intminuteOfDay(long millis, ZoneId zone) The wall-clock minute of the day atmillis.static longplusMonths(long epochDay, int months) The first day of the monthmonthsafter the oneepochDayis in.static longstartOfDay(long millis, ZoneId zone) The start of the daymillisfalls on.static longstartOfEpochDay(long epochDay, ZoneId zone) The instant the dayepochDaystarts at inzone.static longstartOfMonth(long epochDay) The first day of the monthepochDayis in.static longstartOfWeek(long epochDay, int firstDayOfWeek) The first day of the weekepochDayis in, when weeks start onfirstDayOfWeek(ISO, 1 is Monday).
-
Field Details
-
MINUTE
public static final long MINUTEMilliseconds in a minute.- See Also:
-
HOUR
public static final long HOURMilliseconds in an hour.- See Also:
-
DAY
public static final long DAYMilliseconds in a day that has no zone transition in it.- See Also:
-
MINUTES_PER_DAY
public static final int MINUTES_PER_DAYMinutes in a day.- See Also:
-
-
Method Details
-
epochDay
The daymillisfalls on inzone, as a count of days since 1970-01-01. -
startOfEpochDay
The instant the dayepochDaystarts at inzone. -
startOfDay
The start of the daymillisfalls on. -
at
The instant of a wall-clock minute on a day.minuteOfDaymay be1440, which is the start of the following day. -
minuteOfDay
The wall-clock minute of the day atmillis. -
dayOfWeek
public static int dayOfWeek(long epochDay) The ISO day of the week of a day: 1 is Monday, 7 is Sunday. -
startOfWeek
public static long startOfWeek(long epochDay, int firstDayOfWeek) The first day of the weekepochDayis in, when weeks start onfirstDayOfWeek(ISO, 1 is Monday). -
startOfMonth
public static long startOfMonth(long epochDay) The first day of the monthepochDayis in. -
plusMonths
public static long plusMonths(long epochDay, int months) The first day of the monthmonthsafter the oneepochDayis in.
-