Java Timestamp readTimestamp(ObjectInput in, long nullFlag)

Here you can find the source of readTimestamp(ObjectInput in, long nullFlag)

Description

read Timestamp

License

Open Source License

Declaration

public static Timestamp readTimestamp(ObjectInput in, long nullFlag)
            throws ClassNotFoundException, IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.ObjectInput;

import java.sql.Timestamp;

public class Main {
    public static final int NULL = 0x00;
    public static final int NOTNULL = 0x01;

    public static Timestamp readTimestamp(ObjectInput in, long nullFlag)
            throws ClassNotFoundException, IOException {
        Timestamp stamp = null;//from   www.j a v a 2  s  .c om
        long value = in.readLong();
        if (value != nullFlag) {
            stamp = new Timestamp(value);
        }
        return stamp;
    }

    public static Long readLong(ObjectInput in) throws ClassNotFoundException, IOException {
        byte b = in.readByte();
        switch (b) {
        case NULL:
            return null;
        case NOTNULL:
            return in.readLong();
        }
        throw new InvalidObjectException("null flag broken:" + b);
    }

    public static Byte readByte(ObjectInput in) throws ClassNotFoundException, IOException {
        byte b = in.readByte();
        switch (b) {
        case NULL:
            return null;
        case NOTNULL:
            return in.readByte();
        }
        throw new InvalidObjectException("null flag broken:" + b);

    }
}

Related

  1. printFull(Timestamp ts)
  2. quoteMySQLDataField(Timestamp fieldData)
  3. randomTimestamp()
  4. readTimestamp(ByteBuffer logBuf)
  5. readTimestamp(DataInput in)
  6. removeTime(Timestamp ts)
  7. resetHourMinuteSecond(Timestamp timestamp, int hour, int minute, int second)
  8. roundToHour(Timestamp arg)
  9. roundToSecond(Timestamp t)