Class BwDateTime

All Implemented Interfaces:
Serializable, Comparable<BwDateTime>, Comparator<BwDateTime>, BwCloneable, org.bedework.util.logging.Logged

public class BwDateTime extends DumpEntity<BwDateTime> implements BwCloneable, Comparable<BwDateTime>, Comparator<BwDateTime>, Serializable
Class to represent an RFC2445 date and datetime type. These are not stored in separate tables but as components of the including class.

DateTime values take 3 forms:
Floating time - no timezone e.g. DTSTART:19980118T230000
UTC time no timezone e.g. DTSTART:19980118T230000Z
Local time with timezone e.g. DTSTART;TZID=US-Eastern:19980119T020000

Version:
1.0
Author:
Mike Douglass
See Also:
  • Field Details

  • Constructor Details

    • BwDateTime

      public BwDateTime()
      Constructor
  • Method Details

    • makeBwDateTime

      public static BwDateTime makeBwDateTime(boolean dateType, String date, String tzid)
      Constructor
      Parameters:
      dateType - true for date only
      date - date time
      tzid - timezone id
      Returns:
      initialised BwDateTime
      Throws:
      RuntimeException - on bad date
    • makeBwDateTime

      public static BwDateTime makeBwDateTime(boolean dateType, String date, String utcDate, String tzid, boolean floating)
      Make date time based on all properties
      Parameters:
      dateType - true for date only
      date - date time
      utcDate - UTC value
      tzid - timezone id
      floating - true for floating
      Returns:
      initialised BwDateTime
      Throws:
      RuntimeException - on bad date
    • makeBwDateTime

      public static BwDateTime makeBwDateTime(net.fortuna.ical4j.model.property.DateProperty val)
      Make date time based on ical property
      Parameters:
      val - ical date property
      Returns:
      BwDateTime
    • makeBwDateTime

      public static BwDateTime makeBwDateTime(ietf.params.xml.ns.icalendar_2.DateDatetimePropertyType val)
      Make date time based on the xcal property
      Parameters:
      val - xcal date/datetime property
      Returns:
      BwDateTime
    • makeBwDateTime

      public static BwDateTime makeBwDateTime(ietf.params.xml.ns.icalendar_2.DateDatetimePropertyType val, String tzid)
      Make date time based on the xcal property with tzid supplied
      Parameters:
      val - xcal date/datetime property
      tzid - timezone id
      Returns:
      BwDateTime
    • makeBwDateTime

      public static BwDateTime makeBwDateTime(net.fortuna.ical4j.model.Date val)
      Parameters:
      val - Date object
      Returns:
      initialised BwDateTime
    • makeDateTime

      public static BwDateTime makeDateTime(net.fortuna.ical4j.model.property.DateProperty dtStart, boolean dateOnly, String dur)
      Make a new date time value based on the dtStart value + the duration.
      Parameters:
      dtStart - date property
      dateOnly - true for date only value
      dur - duration to increment
      Returns:
      BwDateTime
    • fromUTC

      public static BwDateTime fromUTC(boolean dateType, String date)
      Create from utc time
      Parameters:
      dateType - true for date only
      date - the UTC value
      Returns:
      initialised BwDateTime
      Throws:
      RuntimeException - on bad date
    • fromUTC

      public static BwDateTime fromUTC(boolean dateType, String date, String tzid)
      Create from utc time with timezone
      Parameters:
      dateType - true for a date value
      date - the string UTC date/time or 8 character date
      tzid - tzid for local time
      Returns:
      initialised BwDateTime
    • getDateType

      public boolean getDateType()
      Get the date/times dateType
      Returns:
      boolean true for a date only type
    • getTzid

      public String getTzid()
      Get the tzid
      Returns:
      String tzid
    • setFractional

      public void setFractional(String val)
    • getFractional

      public String getFractional()
    • getDtval

      public String getDtval()
      Get the dtval - the rfc2445 date or datetime value
      Returns:
      String dtval
    • getRange

      public String getRange()
      Get the range for a query
      Returns:
      String range
    • getDate

      public String getDate()
      This is a UTC datetime value to make searching easier. There are a number of complications to dates, the end date is specified as non-inclusive but there are a number of boundary problems to watch out for.

      For date only values this field has a zero time appended so that simple string comparisons will work.

      For floating time values this is the same as the dtval made to look like a UTC value.

      Returns:
      String date
    • getFloatFlag

      public Boolean getFloatFlag()
      Returns:
      Boolean or null
    • getFloating

      public boolean getFloating()
      Returns:
      boolean
    • isUTC

      public boolean isUTC()
      Returns:
      true if this represents a valid UTC date
    • makeDtEnd

      public net.fortuna.ical4j.model.property.DtEnd makeDtEnd()
      Make a DtEnd from this object
      Returns:
      DtEnd ical4j dtend object
    • makeDtEnd

      public net.fortuna.ical4j.model.property.DtEnd makeDtEnd(net.fortuna.ical4j.model.TimeZoneRegistry tzreg)
      Make a DtEnd from this object
      Parameters:
      tzreg - timezone registry
      Returns:
      DtEnd
    • makeDue

      public net.fortuna.ical4j.model.property.Due makeDue(net.fortuna.ical4j.model.TimeZoneRegistry tzreg)
      Make a Due from this object
      Parameters:
      tzreg - timezone registry
      Returns:
      Due
    • copy

      public BwDateTime copy()
      Create a copy of this object
      Returns:
      BwDateTime
    • makeDtStart

      public net.fortuna.ical4j.model.property.DtStart makeDtStart()
      Make a DtStart from this object
      Returns:
      DtStart
    • makeDtStart

      public net.fortuna.ical4j.model.property.DtStart makeDtStart(net.fortuna.ical4j.model.TimeZoneRegistry tzreg)
      Make a DtStart from this object
      Parameters:
      tzreg - timezone registry
      Returns:
      DtStart
    • makeDate

      public net.fortuna.ical4j.model.Date makeDate()
      Return an ical DateTime or Date object
      Returns:
      Date
    • makeDuration

      public static net.fortuna.ical4j.model.Dur makeDuration(BwDateTime start, BwDateTime end)
      Make an ical Dur from a start and end
      Parameters:
      start - bw start object
      end - bw end object
      Returns:
      Dur
    • addDuration

      public BwDateTime addDuration(BwDuration val)
      Return a value based on this value plus a duration.
      Parameters:
      val - bw duration object
      Returns:
      BwDateTime
    • getNextDay

      public BwDateTime getNextDay()
      For a date only object returns a date 1 day in advance of this date. Used when moving between displayed and internal values and also when breaking a collection of events up into days.
      Returns:
      BwDateTime tomorrow
    • getPreviousDay

      public BwDateTime getPreviousDay()
      For a date only object returns a date 1 day previous to this date. Used when moving between displayed and internal values.
      Returns:
      BwDateTime yesterday
    • addDur

      public BwDateTime addDur(String d)
      Add a duration and return the result
      Parameters:
      d - dur value
      Returns:
      BwDateTime
    • compare

      public int compare(BwDateTime dt1, BwDateTime dt2)
      Specified by:
      compare in interface Comparator<BwDateTime>
    • compareTo

      public int compareTo(BwDateTime o2)
      Specified by:
      compareTo in interface Comparable<BwDateTime>
    • before

      public boolean before(BwDateTime val)
      Return true if this is before val
      Parameters:
      val - bw date time
      Returns:
      boolean this before val
    • after

      public boolean after(BwDateTime val)
      Return true if this is after val
      Parameters:
      val - bw date time
      Returns:
      boolean this after val
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • validate

      public int validate()
      Ensure the date time is a valid representation. Provide an indication of reasons why not.
      Returns:
      validity code
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Comparator<BwDateTime>
      Overrides:
      equals in class Object
    • clone

      public Object clone()
      Specified by:
      clone in interface BwCloneable
      Overrides:
      clone in class Object
      Returns:
      a clone of the object
    • toString

      public String toString()
      Overrides:
      toString in class Object