PackedLocalDateTime
public class PackedInstant extends Object
The 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)
Modifier | Constructor | Description |
---|---|---|
protected |
PackedInstant() |
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 added
|
static int |
time(long packedDateTIme) |
|
static String |
toString(long dateTime) |
|
static int |
weeksUntil(long packedDateTimeEnd,
long packedDateStart) |
public static Instant asInstant(long dateTime)
public static long pack(Instant instant)
public static int date(long packedDateTIme)
public static int time(long packedDateTIme)
public static String toString(long dateTime)
public static long plus(long packedDateTime, long amountToAdd, TemporalUnit unit)
TODO(lwhite): Replace with a native implementation that doesn't convert everything to LocalDateTime
public static boolean isAfter(long packedDateTime, long value)
public static boolean isBefore(long packedDateTime, long value)
public static long create(int date, int time)
public static long minutesUntil(long packedDateTimeEnd, long packedDateTimeStart)
public static long hoursUntil(long packedDateTimeEnd, long packedDateTimeStart)
public static int daysUntil(long packedDateTimeEnd, long packedDateTimeStart)
public static int weeksUntil(long packedDateTimeEnd, long packedDateStart)
public static boolean isEqualTo(long packedDateTime, long value)
public static boolean isOnOrAfter(long valueToTest, long valueToTestAgainst)
public static boolean isOnOrBefore(long valueToTest, long valueToTestAgainst)
Copyright © 2022. All rights reserved.