org.knime.core.data.date
Class DateAndTimeCell

java.lang.Object
  extended by org.knime.core.data.DataCell
      extended by org.knime.core.data.date.DateAndTimeCell
All Implemented Interfaces:
Serializable, BoundedValue, DataValue, DateAndTimeValue, StringValue

public class DateAndTimeCell
extends DataCell
implements DateAndTimeValue, BoundedValue, StringValue

Cell storing a time and/or date. Time is represented by a Calendar set to UTC time. No support for time zones. A DateAndTimeCell can be created by passing only the date fields (year, month, day), only the time fields (hour, minute, seconds, and milliseconds).

Author:
Fabian Dill, KNIME.com, Zurich, Switzerland
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.knime.core.data.StringValue
StringValue.StringUtilityFactory
 
Nested classes/interfaces inherited from interface org.knime.core.data.DataValue
DataValue.UtilityFactory
 
Field Summary
static DataType TYPE
          DataType of this cell.
static TimeZone UTC_TIMEZONE
          The UTC time zone used to represent the time.
 
Fields inherited from interface org.knime.core.data.date.DateAndTimeValue
UTILITY
 
Fields inherited from interface org.knime.core.data.StringValue
UTILITY
 
Constructor Summary
DateAndTimeCell(int year, int month, int dayOfMonth)
          A date timestamp without time.
DateAndTimeCell(int hourOfDay, int minute, int second, int milliseconds)
          A timestamp without date.
DateAndTimeCell(int year, int month, int dayOfMonth, int hourOfDay, int minute, int second)
           
DateAndTimeCell(int year, int month, int dayOfMonth, int hourOfDay, int minute, int second, int millisecond)
           
DateAndTimeCell(long utcTime, boolean hasDate, boolean hasTime, boolean hasMillis)
          For internal use only!
 
Method Summary
protected  boolean equalsDataCell(DataCell dc)
          Derived classes implement their specific equals function here.
static DataCellSerializer<DateAndTimeCell> getCellSerializer()
           
 int getDayOfMonth()
          
 int getHourOfDay()
          
(package private)  Calendar getInternalUTCCalendarMember()
          Convenience method to access member UTC Calendar (for faster comparisons/equal tests).
 int getMillis()
          
 int getMinute()
          
 int getMonth()
          
static Class<? extends DataValue> getPreferredValueClass()
          Static method indicating preferred value class as required by DataCell API.
 int getSecond()
          
 String getStringValue()
          
static Calendar getUTCCalendar()
           
 Calendar getUTCCalendarClone()
          
 long getUTCTimeInMillis()
          
 int getYear()
          
 boolean hasDate()
          
 int hashCode()
          This method must be implemented in order to ensure that two equal DataCell objects return the same hash code.
 boolean hasMillis()
          
 boolean hasTime()
          
static DateAndTimeCell load(ConfigRO config)
          Load a data cell that was previously written with the save(ConfigWO) method.
static void resetDateFields(Calendar cal)
           
static void resetTimeFields(Calendar cal)
           
 void save(ConfigWO config)
          Save this cell to the argument config.
 String toString()
          Returns the String representation of this cell's value.
 
Methods inherited from class org.knime.core.data.DataCell
equals, getType, isMissing
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UTC_TIMEZONE

public static final TimeZone UTC_TIMEZONE
The UTC time zone used to represent the time.


TYPE

public static final DataType TYPE
DataType of this cell.

Constructor Detail

DateAndTimeCell

public DateAndTimeCell(int year,
                       int month,
                       int dayOfMonth)
A date timestamp without time.

Parameters:
year - the year
month - the month (1-12)
dayOfMonth - the day of the month (1-31)

DateAndTimeCell

public DateAndTimeCell(int hourOfDay,
                       int minute,
                       int second,
                       int milliseconds)
A timestamp without date.

Parameters:
hourOfDay - the hour of the day
minute - the minute
second - the second
milliseconds - the milliseconds (or <0 if they should not be set)

DateAndTimeCell

public DateAndTimeCell(int year,
                       int month,
                       int dayOfMonth,
                       int hourOfDay,
                       int minute,
                       int second)
Parameters:
year - the year Calendar.YEAR
month - the month Calendar.MONTH
dayOfMonth - day of month Calendar.DAY_OF_MONTH
hourOfDay - hour of day Calendar.HOUR_OF_DAY
minute - minute Calendar.MINUTE
second - second Calendar.SECOND

DateAndTimeCell

public DateAndTimeCell(int year,
                       int month,
                       int dayOfMonth,
                       int hourOfDay,
                       int minute,
                       int second,
                       int millisecond)
Parameters:
year - the year Calendar.YEAR
month - the month Calendar.MONTH
dayOfMonth - day of month Calendar.DAY_OF_MONTH
hourOfDay - hour of day Calendar.HOUR_OF_DAY
minute - minute Calendar.MINUTE
second - second Calendar.SECOND
millisecond - milliseconds Calendar.MILLISECOND (or <0 if they should not be set)

DateAndTimeCell

public DateAndTimeCell(long utcTime,
                       boolean hasDate,
                       boolean hasTime,
                       boolean hasMillis)
For internal use only!

Parameters:
utcTime - milliseconds in UTC time
hasDate - true if the date (year, month ,day) is available
hasTime - true if the time is available (hour, minute, second)
hasMillis - true if milliseconds are available
Method Detail

getPreferredValueClass

public static final Class<? extends DataValue> getPreferredValueClass()
Static method indicating preferred value class as required by DataCell API.

Returns:
DateAndTimeValue.class

resetDateFields

public static void resetDateFields(Calendar cal)
Parameters:
cal - the calendar containing time fields and for which the date fields should be reset Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH

resetTimeFields

public static void resetTimeFields(Calendar cal)
Parameters:
cal - the calendar containing date fields and for which the time fields should be reset Calendar.HOUR, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND

getCellSerializer

public static final DataCellSerializer<DateAndTimeCell> getCellSerializer()
Returns:
serializer for this cell
See Also:
DataCellSerializer, DataCell

getYear

public int getYear()

Specified by:
getYear in interface DateAndTimeValue
Returns:
the year of this date
See Also:
Calendar.YEAR

getMonth

public int getMonth()

Specified by:
getMonth in interface DateAndTimeValue
Returns:
the month of the year, **STARTING WITH 0** for the first month
See Also:
Calendar.MONTH

getDayOfMonth

public int getDayOfMonth()

Specified by:
getDayOfMonth in interface DateAndTimeValue
Returns:
the day of the month in the interval 1-31
See Also:
Calendar.DAY_OF_MONTH

getHourOfDay

public int getHourOfDay()

Specified by:
getHourOfDay in interface DateAndTimeValue
Returns:
the hour of day represented in the interval 0-23
See Also:
Calendar.HOUR_OF_DAY

getMinute

public int getMinute()

Specified by:
getMinute in interface DateAndTimeValue
Returns:
the minute in the interval 0-59
See Also:
Calendar.MINUTE

getSecond

public int getSecond()

Specified by:
getSecond in interface DateAndTimeValue
Returns:
the second in the interval 0-59
See Also:
Calendar.SECOND

getMillis

public int getMillis()

Specified by:
getMillis in interface DateAndTimeValue
Returns:
the milliseconds in the interval 0-999
See Also:
Calendar.MILLISECOND

getStringValue

public String getStringValue()

Specified by:
getStringValue in interface StringValue
Returns:
A String value.

getUTCCalendar

public static final Calendar getUTCCalendar()
Returns:
an emptycalendar where the time zone is set to UTC (as it us used in the timestamp cell) and all fields are empty.

getUTCCalendarClone

public Calendar getUTCCalendarClone()

Specified by:
getUTCCalendarClone in interface DateAndTimeValue
Returns:
a clone of the underlying UTC calendar

getInternalUTCCalendarMember

Calendar getInternalUTCCalendarMember()
Convenience method to access member UTC Calendar (for faster comparisons/equal tests).

Returns:
underlying UTC calendar

getUTCTimeInMillis

public long getUTCTimeInMillis()

Specified by:
getUTCTimeInMillis in interface DateAndTimeValue
Returns:
the milliseconds in UTC time
See Also:
Calendar.getTimeInMillis()

hasDate

public boolean hasDate()

Specified by:
hasDate in interface DateAndTimeValue
Returns:
true if the date is available and it is legal to access the date fields (year, month, day)

hasTime

public boolean hasTime()

Specified by:
hasTime in interface DateAndTimeValue
Returns:
true if the time is available and it is legal to access the time fields (hour, minute, second)

hasMillis

public boolean hasMillis()

Specified by:
hasMillis in interface DateAndTimeValue
Returns:
true if the milliseconds are available and it is legal to access the milliseconds

save

public void save(ConfigWO config)
Save this cell to the argument config. This method writes directly into the config object, no sub-config is created.

Parameters:
config - To save to.
See Also:
load(ConfigRO)

load

public static DateAndTimeCell load(ConfigRO config)
                            throws InvalidSettingsException
Load a data cell that was previously written with the save(ConfigWO) method.

Parameters:
config - To load from.
Returns:
A new cell loaded from the argument.
Throws:
InvalidSettingsException - If the config is incomplete or invalid.

equalsDataCell

protected boolean equalsDataCell(DataCell dc)
Derived classes implement their specific equals function here. The argument is guaranteed to be not null or a missing value, to be of the same class like this.

Specified by:
equalsDataCell in class DataCell
Parameters:
dc - the cell to compare this to
Returns:
true if this is equal to the argument, false if not

hashCode

public int hashCode()
This method must be implemented in order to ensure that two equal DataCell objects return the same hash code.

Specified by:
hashCode in class DataCell
Returns:
the hash code of your specific DataCell
See Also:
Object.hashCode(), DataCell.equals(java.lang.Object)

toString

public String toString()
Returns the String representation of this cell's value.

Specified by:
toString in class DataCell
Returns:
a String representation of this cell's value


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.