Code example for Timestamp

Methods: setNanos

    bd = bd.subtract(new BigDecimal(seconds)).multiply(new BigDecimal(1000000000));
    int nanos = bd.intValue();
    // Convert to millis 
    long millis = seconds * 1000;
    Timestamp t = new Timestamp(millis);
    // Set remaining fractional portion to nanos 
    return t;
  public static void setTimestamp(Timestamp t, byte[] bytes, int offset) {
    t.setTime(((long) TimestampWritable.getSeconds(bytes, offset)) * 1000);
    t.setNanos(TimestampWritable.getNanos(bytes, offset+4));
  public static Timestamp createTimestamp(byte[] bytes, int offset) {
    Timestamp t = new Timestamp(0);
    TimestampWritable.setTimestamp(t, bytes, offset);
Stop searching for code, let great code find you!  Add Codota to your java IDE