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 class
RelativeDate.StartRule
-
Field Summary
Fields Modifier and Type Field Description protected int
dayOfMonth
protected int
dayOfWeek
protected int
hour
protected org.apache.log4j.Logger
logger
protected int
minute
protected int
month
protected static java.util.HashMap<java.lang.String,java.lang.Integer>
months
protected RelativeDate.StartRule
rule
protected int
second
protected static java.util.HashMap<java.lang.String,java.lang.Integer>
weekDays
protected int
year
protected char
zoneChar
-
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.JSONObject
addJson(org.json.JSONObject json)
RelativeDate
clone()
int
compareTo(RelativeDate other)
int
getDayOfMonth()
int
getDayOfWeek()
int
getHour()
int
getMinute()
int
getMonth()
RelativeDate.StartRule
getRule()
int
getSecond()
int
getYear()
char
getZoneChar()
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.void
parse(java.lang.String[] fields, int startIndex)
void
setDayOfMonth(int dayOfMonth)
void
setDayOfWeek(int dayOfWeek)
void
setHour(int hour)
void
setMinute(int minute)
void
setMonth(int month)
void
setRule(RelativeDate.StartRule rule)
void
setSecond(int second)
void
setYear(int year)
void
setZoneChar(char zoneChar)
java.lang.String
toString()
-
-
-
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:
toString
in 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:
compareTo
in 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:
clone
in classjava.lang.Object
-
-