Java Timestamp writeTimestamp(ByteBuffer logBuf, Timestamp time)

Here you can find the source of writeTimestamp(ByteBuffer logBuf, Timestamp time)

Description

Write a timestamp into the log.

License

Open Source License

Declaration

public static void writeTimestamp(ByteBuffer logBuf, Timestamp time) 

Method Source Code


//package com.java2s;
/*-//from w  w  w .j  a v  a2 s.c  o  m
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 2002,2007 Oracle.  All rights reserved.
 *
 * $Id: LogUtils.java,v 1.50.2.1 2007/02/01 14:49:47 cwl Exp $
 */

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

public class Main {
    /**
     * Write a timestamp into the log.
     */
    public static void writeTimestamp(ByteBuffer logBuf, Timestamp time) {
        writeLong(logBuf, time.getTime());
    }

    /**
     * Write a long into the log.
     */
    public static void writeLong(ByteBuffer logBuf, long l) {
        byte b = (byte) (l >>> 0);
        logBuf.put(b);
        b = (byte) (l >>> 8);
        logBuf.put(b);
        b = (byte) (l >>> 16);
        logBuf.put(b);
        b = (byte) (l >>> 24);
        logBuf.put(b);
        b = (byte) (l >>> 32);
        logBuf.put(b);
        b = (byte) (l >>> 40);
        logBuf.put(b);
        b = (byte) (l >>> 48);
        logBuf.put(b);
        b = (byte) (l >>> 56);
        logBuf.put(b);
    }
}

Related

  1. truncateTimestamp(Timestamp timestamp, String period)
  2. truncNanos(Timestamp timestamp)
  3. unformattedFromTimestamp(java.sql.Timestamp t)
  4. utcToTimestamp(String utcTimestamp)
  5. weekNumber(Timestamp stamp, TimeZone timeZone, Locale locale)
  6. writeTimestamp(Timestamp stamp, ObjectOutput out, long nullFlag)