Java Timestamp encodeTimestamp(Timestamp timestamp)

Here you can find the source of encodeTimestamp(Timestamp timestamp)

Description

Encodes a TIMESTAMP value.

License

Apache License

Declaration

public static ByteBuffer encodeTimestamp(Timestamp timestamp) 

Method Source Code

//package com.java2s;
// Licensed to the Apache Software Foundation (ASF) under one

import java.nio.ByteBuffer;
import java.sql.Timestamp;

public class Main {
    /**//w  ww  .  java  2  s.  co  m
     * Encodes a TIMESTAMP value.
     */
    public static ByteBuffer encodeTimestamp(Timestamp timestamp) {
        if (timestamp == null)
            throw new NullPointerException("timestamp cannot be null.");
        ByteBuffer buffer = ByteBuffer.allocate(8 + 4);
        buffer.putLong(timestamp.getTime() / 1000);
        buffer.putInt(timestamp.getNanos());
        buffer.rewind();
        return buffer;
    }
}

Related

  1. daysBetween(Timestamp t1, Timestamp t2)
  2. delta_hours(Timestamp startdate, Timestamp enddate)
  3. differDayByNow(Timestamp timestamp)
  4. doubleToTimestamp(double f)
  5. durationBetween(Timestamp startedAt, Timestamp completedAt)
  6. endOfMonth(java.sql.Timestamp dd)
  7. extractDateSystemTimeStamp()
  8. floorAsDate(Timestamp time)
  9. fromDate(Timestamp timestamp)