Package org.bedework.calfacade
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bedework.calfacade.base.DumpEntity
DumpEntity.DumpType -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd a duration and return the resultaddDuration(BwDuration val) Return a value based on this value plus a duration.booleanafter(BwDateTime val) Return true if this is after valbooleanbefore(BwDateTime val) Return true if this is before valclone()intcompare(BwDateTime dt1, BwDateTime dt2) intcompareTo(BwDateTime o2) copy()Create a copy of this objectbooleanstatic BwDateTimeCreate from utc timestatic BwDateTimeCreate from utc time with timezonegetDate()This is a UTC datetime value to make searching easier.booleanGet the date/times dateTypegetDtval()Get the dtval - the rfc2445 date or datetime valuebooleanFor a date only object returns a date 1 day in advance of this date.For a date only object returns a date 1 day previous to this date.getRange()Get the range for a querygetTzid()Get the tzidinthashCode()booleanisUTC()static BwDateTimemakeBwDateTime(boolean dateType, String date, String tzid) Constructorstatic BwDateTimemakeBwDateTime(boolean dateType, String date, String utcDate, String tzid, boolean floating) Make date time based on all propertiesstatic BwDateTimemakeBwDateTime(ietf.params.xml.ns.icalendar_2.DateDatetimePropertyType val) Make date time based on the xcal propertystatic BwDateTimemakeBwDateTime(ietf.params.xml.ns.icalendar_2.DateDatetimePropertyType val, String tzid) Make date time based on the xcal property with tzid suppliedstatic BwDateTimemakeBwDateTime(net.fortuna.ical4j.model.Date val) static BwDateTimemakeBwDateTime(net.fortuna.ical4j.model.property.DateProperty val) Make date time based on ical propertynet.fortuna.ical4j.model.DatemakeDate()Return an ical DateTime or Date objectstatic BwDateTimemakeDateTime(net.fortuna.ical4j.model.property.DateProperty dtStart, boolean dateOnly, String dur) Make a new date time value based on the dtStart value + the duration.net.fortuna.ical4j.model.property.DtEndMake a DtEnd from this objectnet.fortuna.ical4j.model.property.DtEndmakeDtEnd(net.fortuna.ical4j.model.TimeZoneRegistry tzreg) Make a DtEnd from this objectnet.fortuna.ical4j.model.property.DtStartMake a DtStart from this objectnet.fortuna.ical4j.model.property.DtStartmakeDtStart(net.fortuna.ical4j.model.TimeZoneRegistry tzreg) Make a DtStart from this objectnet.fortuna.ical4j.model.property.DuemakeDue(net.fortuna.ical4j.model.TimeZoneRegistry tzreg) Make a Due from this objectstatic net.fortuna.ical4j.model.DurmakeDuration(BwDateTime start, BwDateTime end) Make an ical Dur from a start and endvoidsetFractional(String val) toString()intvalidate()Ensure the date time is a valid representation.Methods inherited from class org.bedework.calfacade.base.DumpEntity
dump, dump, getLogger, hasDumpValueMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongMethods inherited from interface org.bedework.util.logging.Logged
audit, debug, debug, debug, enableAuditLogger, enableErrorLogger, enableMetricsLogger, error, error, error, getLogLevel, info, isAuditLoggerEnabled, isErrorLoggerEnabled, isMetricsDebugEnabled, isMetricsLoggerEnabled, metrics, setLoggerClass, setLoggerClass, trace, trace, trace, warn
-
Field Details
-
fieldDelimiter
- See Also:
-
oneDayForward
-
oneDayBack
-
dtOk
public static final int dtOk- See Also:
-
dtBadTz
public static final int dtBadTzShould not have a tzid- See Also:
-
dtBadDtval
public static final int dtBadDtval- See Also:
-
-
Constructor Details
-
BwDateTime
public BwDateTime()Constructor
-
-
Method Details
-
makeBwDateTime
Constructor- Parameters:
dateType- true for date onlydate- date timetzid- 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 onlydate- date timeutcDate- UTC valuetzid- timezone idfloating- true for floating- Returns:
- initialised BwDateTime
- Throws:
RuntimeException- on bad date
-
makeBwDateTime
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 propertytzid- timezone id- Returns:
- BwDateTime
-
makeBwDateTime
- 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 propertydateOnly- true for date only valuedur- duration to increment- Returns:
- BwDateTime
-
fromUTC
Create from utc time- Parameters:
dateType- true for date onlydate- the UTC value- Returns:
- initialised BwDateTime
- Throws:
RuntimeException- on bad date
-
fromUTC
Create from utc time with timezone- Parameters:
dateType- true for a date valuedate- the string UTC date/time or 8 character datetzid- 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
Get the tzid- Returns:
- String tzid
-
setFractional
-
getFractional
-
getDtval
Get the dtval - the rfc2445 date or datetime value- Returns:
- String dtval
-
getRange
Get the range for a query- Returns:
- String range
-
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
- 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
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
Make an ical Dur from a start and end- Parameters:
start- bw start objectend- bw end object- Returns:
- Dur
-
addDuration
Return a value based on this value plus a duration.- Parameters:
val- bw duration object- Returns:
- 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
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
Add a duration and return the result- Parameters:
d- dur value- Returns:
- BwDateTime
-
compare
- Specified by:
comparein interfaceComparator<BwDateTime>
-
compareTo
- Specified by:
compareToin interfaceComparable<BwDateTime>
-
before
Return true if this is before val- Parameters:
val- bw date time- Returns:
- boolean this before val
-
after
Return true if this is after val- Parameters:
val- bw date time- Returns:
- boolean this after val
-
hashCode
public int hashCode() -
validate
public int validate()Ensure the date time is a valid representation. Provide an indication of reasons why not.- Returns:
- validity code
-
equals
- Specified by:
equalsin interfaceComparator<BwDateTime>- Overrides:
equalsin classObject
-
clone
- Specified by:
clonein interfaceBwCloneable- Overrides:
clonein classObject- Returns:
- a clone of the object
-
toString
-