Java Timestamp readTimestamp(ByteBuffer logBuf)

Here you can find the source of readTimestamp(ByteBuffer logBuf)

Description

Read a timestamp from the log.

License

Open Source License

Declaration

public static Timestamp readTimestamp(ByteBuffer logBuf) 

Method Source Code


//package com.java2s;
/*-//from   w  ww.  jav 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 {
    /**
     * Read a timestamp from the log.
     */
    public static Timestamp readTimestamp(ByteBuffer logBuf) {
        long millis = readLong(logBuf);
        return new Timestamp(millis);
    }

    /**
     * Read a long from the log.
     */
    public static long readLong(ByteBuffer logBuf) {
        long ret = (logBuf.get() & 0xFFL) << 0;
        ret += (logBuf.get() & 0xFFL) << 8;
        ret += (logBuf.get() & 0xFFL) << 16;
        ret += (logBuf.get() & 0xFFL) << 24;
        ret += (logBuf.get() & 0xFFL) << 32;
        ret += (logBuf.get() & 0xFFL) << 40;
        ret += (logBuf.get() & 0xFFL) << 48;
        ret += (logBuf.get() & 0xFFL) << 56;
        return ret;
    }
}

Related

  1. nowUtcTimestamp()
  2. objToTimeStamp(Object obj)
  3. printFull(Timestamp ts)
  4. quoteMySQLDataField(Timestamp fieldData)
  5. randomTimestamp()
  6. readTimestamp(DataInput in)
  7. readTimestamp(ObjectInput in, long nullFlag)
  8. removeTime(Timestamp ts)
  9. resetHourMinuteSecond(Timestamp timestamp, int hour, int minute, int second)