Class RawTime

All Implemented Interfaces:
PofConstants

public class RawTime extends PofHelper
An immutable POF time value.
Since:
Coherence 3.2
Author:
cp 2006.07.17
  • Constructor Details

    • RawTime

      public RawTime(int nHour, int nMinute, int nSecond, int nNano, boolean fUTC)
      Construct a raw POF time value.
      Parameters:
      nHour - the hour between 0 and 23 inclusive
      nMinute - the minute value between 0 and 59 inclusive
      nSecond - the second value between 0 and 59 inclusive (and theoretically 60 for a leap-second)
      nNano - the nanosecond value between 0 and 999999999 inclusive
      fUTC - true if the time value is UTC or false if the time value does not have an explicit time zone
    • RawTime

      public RawTime(int nHour, int nMinute, int nSecond, int nNano, int nHourOffset, int nMinuteOffset)
      Construct a raw POF time value with a timezone.
      Parameters:
      nHour - the hour between 0 and 23 inclusive
      nMinute - the minute value between 0 and 59 inclusive
      nSecond - the second value between 0 and 59 inclusive (and theoretically 60 for a leap-second)
      nNano - the nanosecond value between 0 and 999999999 inclusive
      nHourOffset - the timezone offset in hours from UTC, for example 0 for BST, -5 for EST and 1 for CET
      nMinuteOffset - the timezone offset in minutes, for example 0 (in most cases) or 30
  • Method Details

    • getHour

      public int getHour()
      Determine the time's hour value.
      Returns:
      the hour between 0 and 23 inclusive
    • getMinute

      public int getMinute()
      Determine the time's minute value.
      Returns:
      the minute value between 0 and 59 inclusive
    • getSecond

      public int getSecond()
      Determine the time's second value.
      Returns:
      the second value between 0 and 59 inclusive (and possibly 60 for a leap-second)
    • getNano

      public int getNano()
      Determine the time's nanosecond value.
      Returns:
      the nanosecond value between 0 and 999999999 inclusive
    • hasTimezone

      public boolean hasTimezone()
      Determine if the time value has an explicit timezone. A time value without an explicit timezone is assumed to be in some conventional local timezone, according to ISO8601.
      Returns:
      true iff the time has an explicit timezone
    • isUTC

      public boolean isUTC()
      Determine if the time value uses UTC.
      Returns:
      true if the time value is a UTC value
    • getHourOffset

      public int getHourOffset()
      Determine the timezone's hour offset value.
      Returns:
      the hour offset of the timezeone, or zero if there is no explicit timezone or the time is UTC
    • getMinuteOffset

      public int getMinuteOffset()
      Determine the timezone's minute offset value.
      Returns:
      the minute offset of the timezeone, or zero if there is no explicit timezone or the time is UTC
    • from

      public static RawTime from(Object o)
      Create RawTime from the specified object.
      Parameters:
      o - an object to create RawTime from.
      Returns:
      a RawTime value
      Throws:
      IllegalArgumentException - if the specified object cannot be converted to RawTime
    • from

      public static RawTime from(LocalTime time)
      Create RawTime from LocalTime.
      Parameters:
      time - time to create raw time from
      Returns:
      a RawTime value
    • from

      public static RawTime from(OffsetTime time)
      Create RawTime from OffsetTime.
      Parameters:
      time - time to create raw time from
      Returns:
      a RawTime value
    • from

      public static RawTime from(Time time)
      Create a RawTime from the JDBC Time.
      Parameters:
      time - a Time value
      Returns:
      a RawTime value
    • from

      public static RawTime from(Date date)
      Create a RawTime from the Java Date.
      Parameters:
      date - a Date value
      Returns:
      a RawTime value
    • toLocalTime

      public LocalTime toLocalTime()
      Create a LocalTime from the raw time information.
      Returns:
      a LocalTime value
    • toOffsetTime

      public OffsetTime toOffsetTime()
      Create a OffsetTime from the raw time information.
      Returns:
      a OffsetTime value
      Throws:
      IllegalStateException - if this RawTime does not have time zone information
    • toSqlTime

      public Time toSqlTime()
      Create a JDBC Time from the raw time information. Note that the JDBC Time does not include second, nano or timezone information.
      Returns:
      a JDBC Time value
    • toJavaDate

      public Date toJavaDate()
      Create a Java Date from the raw time information.
      Returns:
      a Java Date value
    • equals

      public boolean equals(Object o)
      Compare this object with another for equality.
      Overrides:
      equals in class Object
      Parameters:
      o - another object to compare to for equality
      Returns:
      true iff this object is equal to the other object
    • hashCode

      public int hashCode()
      Obtain the hashcode for this object.
      Overrides:
      hashCode in class Object
      Returns:
      an integer hashcode
    • toString

      public String toString()
      Format this object's data as a human-readable string.
      Overrides:
      toString in class Object
      Returns:
      a string description of this object