com.google.visualization.datasource.datatable.value
Class DateTimeValue

java.lang.Object
  extended by com.google.visualization.datasource.datatable.value.Value
      extended by com.google.visualization.datasource.datatable.value.DateTimeValue
All Implemented Interfaces:
java.lang.Comparable<Value>

public class DateTimeValue
extends Value

A value of type date-time. Used to represent a specific day in a given year as well as a specific time during that day. This differs from DateValue, which represents only a specific day in a given year. DateTime is represented internally by a GregorianCalendar. The calendar is immutable and is kept only for validation of the input.

Author:
Hillel M.

Constructor Summary
DateTimeValue(com.ibm.icu.util.GregorianCalendar calendar)
          Creates a new instance based on the given GregorianCalendar.
DateTimeValue(int year, int month, int dayOfMonth, int hours, int minutes, int seconds, int milliseconds)
          Creates a new DateTime value.
 
Method Summary
 int compareTo(Value other)
          Compares this value to another value of the same type.
 com.ibm.icu.util.GregorianCalendar getCalendar()
          Returns the internal GregorianCalendar.
 int getDayOfMonth()
          Returns the day of month.
 int getHourOfDay()
          Returns the hour of day.
 int getMillisecond()
          Returns the millisecond.
 int getMinute()
          Returns the minute.
 int getMonth()
          Returns the month.
static DateTimeValue getNullValue()
          Static method to return the null value (same one for all calls).
 com.ibm.icu.util.Calendar getObjectToFormat()
          Uses an ibm.icu.text.UFormat instance to format Values.
 int getSecond()
          Returns the second.
 ValueType getType()
          Returns the type of this cell.
 int getYear()
          Returns the year.
 int hashCode()
          Returns the hashcode of this value.
protected  java.lang.String innerToQueryString()
          Returns a string that, when parsed by the query parser, should return an identical value.
 boolean isNull()
          Tests whether this value is a logical null.
 java.lang.String toString()
          Returns the DateTimeValue as a String using default formatting.
 
Methods inherited from class com.google.visualization.datasource.datatable.value.Value
equals, getLocalizedComparator, getNullValueFromValueType, toQueryString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DateTimeValue

public DateTimeValue(int year,
                     int month,
                     int dayOfMonth,
                     int hours,
                     int minutes,
                     int seconds,
                     int milliseconds)
Creates a new DateTime value. The input is checked using a gregorian calendar. Note this uses the java convention for months: January = 0, ..., December = 11.

Parameters:
year - The year.
month - The month.
dayOfMonth - The day of month.
hours - The hours.
minutes - The minutes.
seconds - The seconds.
milliseconds - The milliseconds.
Throws:
java.lang.IllegalArgumentException - Thrown if one of the parameters is illegal.

DateTimeValue

public DateTimeValue(com.ibm.icu.util.GregorianCalendar calendar)
Creates a new instance based on the given GregorianCalendar. The given calendar's time zone must be set to "GMT" as a precondition to use this constructor. Note: The date time values: year, month, dayOfMonth, hour, minute, second and millisecond correspond to the values returned by calendar.get(field) of the given calendar.

Parameters:
calendar - A Gregorian calendar on which to base this instance.
Throws:
java.lang.IllegalArgumentException - When calendar time zone is not set to GMT.
Method Detail

getNullValue

public static DateTimeValue getNullValue()
Static method to return the null value (same one for all calls).

Returns:
Null value.

getYear

public int getYear()
Returns the year.

Returns:
The year.

getMonth

public int getMonth()
Returns the month. The values are from 0 (January) to 11 (December).

Returns:
The month.

getDayOfMonth

public int getDayOfMonth()
Returns the day of month. The first day of the month is 1.

Returns:
The day of month.

getHourOfDay

public int getHourOfDay()
Returns the hour of day.

Returns:
The hour of day.

getMinute

public int getMinute()
Returns the minute.

Returns:
The minute.

getSecond

public int getSecond()
Returns the second.

Returns:
The second.

getMillisecond

public int getMillisecond()
Returns the millisecond.

Returns:
The millisecond.

getType

public ValueType getType()
Description copied from class: Value
Returns the type of this cell.

Specified by:
getType in class Value
Returns:
The type of this cell.

toString

public java.lang.String toString()
Returns the DateTimeValue as a String using default formatting.

Overrides:
toString in class java.lang.Object
Returns:
The DateTimeValue as a String using default formatting.

isNull

public boolean isNull()
Tests whether this value is a logical null.

Specified by:
isNull in class Value
Returns:
Indication if the value is null.

compareTo

public int compareTo(Value other)
Compares this value to another value of the same type.

Parameters:
other - Other value.
Returns:
0 if equal, negative if this is smaller, positive if larger.

hashCode

public int hashCode()
Description copied from class: Value
Returns the hashcode of this value. This is introduced here to force the subclasses to define this function.

Specified by:
hashCode in class Value
Returns:
The hashcode of this value.

getObjectToFormat

public com.ibm.icu.util.Calendar getObjectToFormat()
Description copied from class: Value
Uses an ibm.icu.text.UFormat instance to format Values. The following method returns an object representing this Value that a UFormat can format.

Specified by:
getObjectToFormat in class Value
Returns:
An object representing this value that can be formatted by a UFormat formatter, null for a NULL_VALUE.

getCalendar

public com.ibm.icu.util.GregorianCalendar getCalendar()
Returns the internal GregorianCalendar.

Returns:
The internal GregorianCalendar.
Throws:
NullValueException - Thrown when this Value is NULL_VALUE.

innerToQueryString

protected java.lang.String innerToQueryString()
Returns a string that, when parsed by the query parser, should return an identical value. Assumes this value is not null.

Specified by:
innerToQueryString in class Value
Returns:
A string form of this value.


Copyright © 2009 Google. All Rights Reserved.