Package tech.tablesaw.columns.instant
Class PackedInstant
- java.lang.Object
-
- tech.tablesaw.columns.instant.PackedInstant
-
- Direct Known Subclasses:
PackedLocalDateTime
public class PackedInstant extends Object
A short localdatetime packed into a single long value. The long is comprised of an int for the date and an int for the timeThe bytes are packed into the date int as: First two bytes: short (year) next byte (month of year) last byte (day of month)
The bytes are packed into the time int as First byte: hourOfDay next byte: minuteOfHour last two bytes (short): millisecond of minute
Storing the millisecond of minute in an short requires that we treat the short as if it were unsigned. Unfortunately, Neither Java nor Guava provide unsigned short support so we use char, which is a 16-bit unsigned int to store values of up to 60,000 milliseconds (60 secs * 1000)
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPackedInstant()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static InstantasInstant(long dateTime)static longcreate(int date, int time)static intdate(long packedDateTIme)static intdaysUntil(long packedDateTimeEnd, long packedDateTimeStart)static longhoursUntil(long packedDateTimeEnd, long packedDateTimeStart)static booleanisAfter(long packedDateTime, long value)static booleanisBefore(long packedDateTime, long value)static booleanisEqualTo(long packedDateTime, long value)static booleanisOnOrAfter(long valueToTest, long valueToTestAgainst)static booleanisOnOrBefore(long valueToTest, long valueToTestAgainst)static longminutesUntil(long packedDateTimeEnd, long packedDateTimeStart)static longpack(Instant instant)protected static longpack(LocalDate date, LocalTime time)static longplus(long packedDateTime, long amountToAdd, TemporalUnit unit)Returns the given packedDateTime with amtToAdd of temporal units addedstatic inttime(long packedDateTIme)static StringtoString(long dateTime)static intweeksUntil(long packedDateTimeEnd, long packedDateStart)
-
-
-
Method Detail
-
asInstant
public static Instant asInstant(long dateTime)
-
pack
public static long pack(Instant instant)
-
date
public static int date(long packedDateTIme)
-
time
public static int time(long packedDateTIme)
-
toString
public static String toString(long dateTime)
-
plus
public static long plus(long packedDateTime, long amountToAdd, TemporalUnit unit)Returns the given packedDateTime with amtToAdd of temporal units addedTODO(lwhite): Replace with a native implementation that doesn't convert everything to Instant
-
isAfter
public static boolean isAfter(long packedDateTime, long value)
-
isBefore
public static boolean isBefore(long packedDateTime, long value)
-
create
public static long create(int date, int time)
-
minutesUntil
public static long minutesUntil(long packedDateTimeEnd, long packedDateTimeStart)
-
hoursUntil
public static long hoursUntil(long packedDateTimeEnd, long packedDateTimeStart)
-
daysUntil
public static int daysUntil(long packedDateTimeEnd, long packedDateTimeStart)
-
weeksUntil
public static int weeksUntil(long packedDateTimeEnd, long packedDateStart)
-
isEqualTo
public static boolean isEqualTo(long packedDateTime, long value)
-
isOnOrAfter
public static boolean isOnOrAfter(long valueToTest, long valueToTestAgainst)
-
isOnOrBefore
public static boolean isOnOrBefore(long valueToTest, long valueToTestAgainst)
-
-