org.apache.hadoop.hive.serde2.io
Class DateWritable

java.lang.Object
  extended by org.apache.hadoop.hive.serde2.io.DateWritable
All Implemented Interfaces:
Comparable<DateWritable>, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable<DateWritable>

public class DateWritable
extends Object
implements org.apache.hadoop.io.WritableComparable<DateWritable>

DateWritable Writable equivalent of java.sql.Date. Dates are of the format YYYY-MM-DD


Constructor Summary
DateWritable()
           
DateWritable(Date d)
           
DateWritable(DateWritable d)
           
DateWritable(int d)
           
 
Method Summary
 int compareTo(DateWritable d)
           
static int dateToDays(Date d)
           
static long daysToMillis(int d)
           
 boolean equals(Object o)
           
 Date get()
           
 int getDays()
           
 long getTimeInSeconds()
           
 int hashCode()
           
 void readFields(DataInput in)
           
 void set(Date d)
          Set the DateWritable based on the year/month/day of the date in the local timezone.
 void set(DateWritable d)
           
 void set(int d)
          Set the DateWritable based on the days since epoch date.
 void setFromBytes(byte[] bytes, int offset, int length, LazyBinaryUtils.VInt vInt)
           
static Date timeToDate(long l)
           
 String toString()
           
 void write(DataOutput out)
           
 void writeToByteStream(ByteStream.Output byteStream)
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DateWritable

public DateWritable()

DateWritable

public DateWritable(DateWritable d)

DateWritable

public DateWritable(Date d)

DateWritable

public DateWritable(int d)
Method Detail

set

public void set(int d)
Set the DateWritable based on the days since epoch date.

Parameters:
d - integer value representing days since epoch date

set

public void set(Date d)
Set the DateWritable based on the year/month/day of the date in the local timezone.

Parameters:
d - Date value

set

public void set(DateWritable d)

get

public Date get()
Returns:
Date value corresponding to the date in the local time zone

getDays

public int getDays()

getTimeInSeconds

public long getTimeInSeconds()
Returns:
time in seconds corresponding to this DateWritable

timeToDate

public static Date timeToDate(long l)

daysToMillis

public static long daysToMillis(int d)

dateToDays

public static int dateToDays(Date d)

setFromBytes

public void setFromBytes(byte[] bytes,
                         int offset,
                         int length,
                         LazyBinaryUtils.VInt vInt)

writeToByteStream

public void writeToByteStream(ByteStream.Output byteStream)

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

compareTo

public int compareTo(DateWritable d)
Specified by:
compareTo in interface Comparable<DateWritable>

equals

public boolean equals(Object o)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2014 The Apache Software Foundation. All rights reserved.