Package com.ilib.tools.zic
Class RelativeDate
- java.lang.Object
-
- com.ilib.tools.zic.RelativeDate
-
- All Implemented Interfaces:
java.lang.Comparable<RelativeDate>
public class RelativeDate extends java.lang.Object implements java.lang.Comparable<RelativeDate>
RelativeDate - models the specification of a relative date. The following types of dates can be modelled:- First DOW of the month, where DOW is the "day of week". eg. "first Sunday of the month"
- Last DOW of the month. eg. "last Sunday of the month"
- First DOW on or after date. eg. "First Sunday on or after the 8th of the month"
- First DOW on or before date. eg. "First Sunday on or before the 25th of the month"
- A specific day of the month. eg. "May 8".
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRelativeDate.StartRule
-
Field Summary
Fields Modifier and Type Field Description protected intdayOfMonthprotected intdayOfWeekprotected inthourprotected org.apache.log4j.Loggerloggerprotected intminuteprotected intmonthprotected static java.util.HashMap<java.lang.String,java.lang.Integer>monthsprotected RelativeDate.StartRuleruleprotected intsecondprotected static java.util.HashMap<java.lang.String,java.lang.Integer>weekDaysprotected intyearprotected charzoneChar
-
Constructor Summary
Constructors Constructor Description RelativeDate()RelativeDate(RelativeDate.StartRule rule, int dayOfWeek, int dayOfMonth, int month)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.json.JSONObjectaddJson(org.json.JSONObject json)RelativeDateclone()intcompareTo(RelativeDate other)intgetDayOfMonth()intgetDayOfWeek()intgetHour()intgetMinute()intgetMonth()RelativeDate.StartRulegetRule()intgetSecond()intgetYear()chargetZoneChar()voidoffsetToWallTime(int offsetHour, int offsetMinute, int savingsHour, int savingsMinute)If the current relative date has a zone char and that zone char is not "w", then the transition time was given as a standard time or as a UTC time instead of wall time.voidparse(java.lang.String[] fields, int startIndex)voidsetDayOfMonth(int dayOfMonth)voidsetDayOfWeek(int dayOfWeek)voidsetHour(int hour)voidsetMinute(int minute)voidsetMonth(int month)voidsetRule(RelativeDate.StartRule rule)voidsetSecond(int second)voidsetYear(int year)voidsetZoneChar(char zoneChar)java.lang.StringtoString()
-
-
-
Field Detail
-
months
protected static java.util.HashMap<java.lang.String,java.lang.Integer> months
-
weekDays
protected static java.util.HashMap<java.lang.String,java.lang.Integer> weekDays
-
rule
protected RelativeDate.StartRule rule
-
year
protected int year
-
month
protected int month
-
dayOfWeek
protected int dayOfWeek
-
dayOfMonth
protected int dayOfMonth
-
hour
protected int hour
-
minute
protected int minute
-
second
protected int second
-
zoneChar
protected char zoneChar
-
logger
protected org.apache.log4j.Logger logger
-
-
Constructor Detail
-
RelativeDate
public RelativeDate()
-
RelativeDate
public RelativeDate(RelativeDate.StartRule rule, int dayOfWeek, int dayOfMonth, int month)
-
-
Method Detail
-
parse
public void parse(java.lang.String[] fields, int startIndex)
-
offsetToWallTime
public void offsetToWallTime(int offsetHour, int offsetMinute, int savingsHour, int savingsMinute)If the current relative date has a zone char and that zone char is not "w", then the transition time was given as a standard time or as a UTC time instead of wall time. Either way, ilib needs to have the wall time in order to do the correct rule start calculations. This method converts non-wall-time relative dates to a wall time.- Parameters:
offset- the offset from UTC for this rule in hourssavings- the DST savings for this rule in hours
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setRule
public void setRule(RelativeDate.StartRule rule)
- Parameters:
rule- the rule to set
-
getRule
public RelativeDate.StartRule getRule()
-
getYear
public int getYear()
- Returns:
- the year
-
setYear
public void setYear(int year)
- Parameters:
year- the year to set
-
getMonth
public int getMonth()
- Returns:
- the month
-
setMonth
public void setMonth(int month)
- Parameters:
month- the month to set
-
getDayOfWeek
public int getDayOfWeek()
- Returns:
- the dayOfWeek
-
setDayOfWeek
public void setDayOfWeek(int dayOfWeek)
- Parameters:
dayOfWeek- the dayOfWeek to set
-
getDayOfMonth
public int getDayOfMonth()
- Returns:
- the dayOfMonth
-
setDayOfMonth
public void setDayOfMonth(int dayOfMonth)
- Parameters:
dayOfMonth- the dayOfMonth to set
-
getHour
public int getHour()
- Returns:
- the hour
-
setHour
public void setHour(int hour)
- Parameters:
hour- the hour to set
-
getMinute
public int getMinute()
- Returns:
- the minute
-
setMinute
public void setMinute(int minute)
- Parameters:
minute- the minute to set
-
getSecond
public int getSecond()
- Returns:
- the second
-
setSecond
public void setSecond(int second)
- Parameters:
second- the second to set
-
getZoneChar
public char getZoneChar()
- Returns:
- the zoneChar
-
setZoneChar
public void setZoneChar(char zoneChar)
- Parameters:
zoneChar- the zoneChar to set
-
compareTo
public int compareTo(RelativeDate other)
- Specified by:
compareToin interfacejava.lang.Comparable<RelativeDate>
-
addJson
public org.json.JSONObject addJson(org.json.JSONObject json) throws org.json.JSONException- Throws:
org.json.JSONException
-
clone
public RelativeDate clone()
- Overrides:
clonein classjava.lang.Object
-
-