Java Timestamp writeTimestamp(Timestamp stamp, ObjectOutput out, long nullFlag)

Here you can find the source of writeTimestamp(Timestamp stamp, ObjectOutput out, long nullFlag)

Description

write Timestamp

License

Open Source License

Declaration

public static void writeTimestamp(Timestamp stamp, ObjectOutput out, long nullFlag) throws IOException 

Method Source Code

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

import java.io.IOException;

import java.io.ObjectOutput;

import java.sql.Timestamp;

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

    public static void writeTimestamp(Timestamp stamp, ObjectOutput out, long nullFlag) throws IOException {
        if (stamp != null) {
            long value = stamp.getTime();
            out.writeLong(value);/* w ww  .ja va  2  s . c  o  m*/
        } else {
            out.writeLong(nullFlag);
        }
    }

    public static void writeLong(Long num, ObjectOutput out) throws IOException {
        if (num == null) {
            out.writeByte(NULL);
        } else {
            out.writeByte(NOTNULL);
            out.writeLong(num);
        }
    }

    public static void writeByte(Byte num, ObjectOutput out) throws IOException {
        if (num == null) {
            out.writeByte(NULL);
        } else {
            out.writeByte(NOTNULL);
            out.writeByte(num);
        }
    }
}

Related

  1. truncNanos(Timestamp timestamp)
  2. unformattedFromTimestamp(java.sql.Timestamp t)
  3. utcToTimestamp(String utcTimestamp)
  4. weekNumber(Timestamp stamp, TimeZone timeZone, Locale locale)
  5. writeTimestamp(ByteBuffer logBuf, Timestamp time)