Created
January 15, 2014 23:28
-
-
Save GLitchfield/8446844 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final static byte encodeTimeStampByte(final int timeField) { | |
return (byte) (timeField | DDF_TIME_STAMP_MASK); | |
} | |
// | |
// /** time zone information is discarded */ | |
static final void encodeTimeStamp(final ReadableDateTime dateTime, final ByteBuffer buffer) { | |
// base fields | |
buffer.put(DDF_CENTURY); // century | |
buffer.put(encodeTimeStampByte(dateTime.getYearOfCentury())); // year | |
buffer.put(encodeTimeStampByte(dateTime.getMonthOfYear())); // month | |
buffer.put(encodeTimeStampByte(dateTime.getDayOfMonth())); // day | |
buffer.put(encodeTimeStampByte(dateTime.getHourOfDay())); // hours | |
buffer.put(encodeTimeStampByte(dateTime.getMinuteOfHour())); // minutes | |
buffer.put(encodeTimeStampByte(dateTime.getSecondOfMinute())); // seconds | |
// milliseconds | |
final int millisOfSecond = dateTime.getMillisOfSecond(); | |
buffer.put((byte) (millisOfSecond & 0xFF)); // low byte | |
buffer.put((byte) ((millisOfSecond >>> 8) & 0xFF)); // high byte | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment