public class TimeTools extends Object
Constructor and Description 

TimeTools() 
Modifier and Type  Method and Description 

static TimeParts.HMSF 
computeHMS(long totalSeconds)
Extract hours, minutes and seconds from totalSeconds.

static TimeParts.HMSF 
computeHMS(long totalSeconds,
int subSeconds)
Extract hours, minutes and seconds from totalSeconds.

static int[] 
computeMonthAndDay(long year,
int day)
Return an array with the month and the day for the given year and day in year.

static TimeParts.YMD 
computeYMD(long days)
Extract years, month of year and day of month from total days.

static long 
dayIndex(Resolution unit,
long time)
Return the day index computed from the uncompressed numerical time.

static int 
daysInMonth(long year,
int month)
Return the number of days for the indicated year and month.

static int 
daysToMonth(long year,
int month)
Return the number of days in the year before the indicated month.

static long 
diff(long a,
long b)
Return the difference between two positive or negative long integers.

static int 
getDayByRank(long year,
int month,
DayOfWeek name,
int rank)
Return the day number of the month or of the year given the day's name and rank.

static Day 
getDayOfMonthByRank(TimeIndex time,
DayOfWeek dayName,
int rank)
Return the TimeIndex for the day defined by name and rank within the
month of the indicated date.

static DayOfWeek 
getDayOfWeek(Resolution unit,
long time)
Return the day of week for the given unit and uncompressed time index.

static Day 
getDayOfYearByRank(TimeIndex time,
DayOfWeek dayName,
int rank)
Return the TimeIndex for the day defined by name and rank within the year
of the indicated date.

static boolean 
isLeap(long year)
Return true if the given year is a leap year.

static long 
leapYears(long year)
Return the number of leap years between year 0 and the year preceding the given
year.

static long 
makeRawIndex(Resolution unit,
TimeParts tp)
Return a long number representing a time parts object.

static long 
prod(long a,
long b)
Return the product of two positive or negative long integers.

static long 
sum(long a,
long b)
Return the sum of two positive or negative long integers.

public static int daysInMonth(long year, int month)
year
 a nonnegative numbermonth
 a number in the range [1, 12]public static int daysToMonth(long year, int month)
year
 a nonnegative numbermonth
 a number between 1 and 12public static boolean isLeap(long year)
year
 a nonnegative numberpublic static long leapYears(long year)
year
 a nonnegative numberpublic static int[] computeMonthAndDay(long year, int day)
year
 a nonnegative numberday
 the day number of the year, with the first day = 1public static TimeParts.HMSF computeHMS(long totalSeconds)
totalSeconds
 a nonnegative numberpublic static TimeParts.HMSF computeHMS(long totalSeconds, int subSeconds)
totalSeconds
 a nonnegative numbersubSeconds
 a nonnegative number of subsecondspublic static TimeParts.YMD computeYMD(long days)
days
 a nonnegative numberpublic static long makeRawIndex(Resolution unit, TimeParts tp) throws T2Exception
Two special features of the ISO 8601 standard are supported:
Note about leap seconds
When a 61st second occurs in the input for a day when leap seconds are
tolerated, the software simply changes it into the 60th second. This is the
only case in the Time2 Library where leap seconds play a role. When
constructing a time with TimeIndex.add(long)
for example, leap
seconds play no role. Adding 1 second to a "secondbysecond" domain
TimeIndex represented by 20081231T23:59:59 yields 20090101T00:00:00
instead of the official leap second 20081231T23:59:60.
unit
 a nonnull resolutiontp
 time represented in a time parts objectT2Exception
public static long dayIndex(Resolution unit, long time) throws T2Exception
unit
 a non null resolutiontime
 a nonnegative numerical time indexT2Exception
public static DayOfWeek getDayOfWeek(Resolution unit, long time) throws T2Exception
time
 an uncompressed numerical timeDayOfWeek
T2Exception
public static int getDayByRank(long year, int month, DayOfWeek name, int rank) throws T2Exception
year
 a nonnegative numbermonth
 a number in [1, 12] for the day of the month, 0 for the day of the yearname
 the day of weekrank
 a nonzero number in the range [5, 5] or [53, 53]T2Exception
public static Day getDayOfMonthByRank(TimeIndex time, DayOfWeek dayName, int rank) throws T2Exception
getDayOfMonthByRank(DayOfWeek.Mon, 1)
returns the last Monday of the month. If the day does not
exist, like for a 5th Monday of a month with only four Mondays, the
method returns null.time
 the reference timedayName
 the day of weekrank
 a nonzero number in the range [5, 5]T2Exception
public static Day getDayOfYearByRank(TimeIndex time, DayOfWeek dayName, int rank) throws T2Exception
time
 the reference timedayName
 the day of weekrank
 a nonzero number in the range [53, 53]T2Exception
public static long sum(long a, long b)
a
 first termb
 second termArithmeticException
 if the sum is too largepublic static long diff(long a, long b)
a
 first termb
 second termArithmeticException
 if the difference is too largepublic static long prod(long a, long b)
a
 first factorb
 second factorArithmeticException
 if the product is too largeCopyright © 2017. All rights reserved.