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 protected
PackedInstant()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Instant
asInstant(long dateTime)
static long
create(int date, int time)
static int
date(long packedDateTIme)
static int
daysUntil(long packedDateTimeEnd, long packedDateTimeStart)
static long
hoursUntil(long packedDateTimeEnd, long packedDateTimeStart)
static boolean
isAfter(long packedDateTime, long value)
static boolean
isBefore(long packedDateTime, long value)
static boolean
isEqualTo(long packedDateTime, long value)
static boolean
isOnOrAfter(long valueToTest, long valueToTestAgainst)
static boolean
isOnOrBefore(long valueToTest, long valueToTestAgainst)
static long
minutesUntil(long packedDateTimeEnd, long packedDateTimeStart)
static long
pack(Instant instant)
protected static long
pack(LocalDate date, LocalTime time)
static long
plus(long packedDateTime, long amountToAdd, TemporalUnit unit)
Returns the given packedDateTime with amtToAdd of temporal units addedstatic int
time(long packedDateTIme)
static String
toString(long dateTime)
static int
weeksUntil(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)
-
-