Package com.redwood.scheduler.api.date
Class DateTimeZone
- java.lang.Object
-
- com.redwood.scheduler.api.date.DateTimeZone
-
- All Implemented Interfaces:
Serializable
,Comparable<DateTimeZone>
,Temporal
,TemporalAccessor
public class DateTimeZone extends Object implements Serializable, Comparable<DateTimeZone>, Temporal
A Date with a time zone.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
ANYDAY
Wildcard for any single day.static int
DAY_MILLIS
Number of milliseconds in an day.static int
DAYS_IN_WEEK
Number of days in weekstatic int
FIVE_MINUTES_MILLIS
static int
FRIDAY
Value for Fridaystatic DateTimeZone
HIGHEST_SPECIAL_DATE_TIME_ZONE
The dates before this should not be considered normal date values.static long
HIGHEST_SPECIAL_DATE_TIME_ZONE_MILLIS
static int
HOUR_MILLIS
Number of milliseconds in an hour.static int
HOURS_IN_DAY
Number of hours in daystatic int
LASTANYDAY
A special value meaning 'the last day of the month'.static int
LASTWORKDAY
A special value meaning 'the last working day of the month'.static int
MAX_DAYS_IN_MONTH
The maximum number of days in monthstatic int
MAX_RECURRENCE_INTERVAL
The maximum size of an interval that can be specified in a recurrencestatic int
MAX_WEEKS_IN_MONTH
The maximum number of (partial) weeks in monthstatic int
MAX_WORK_DAYS_IN_MONTH
The maximum number of workdays in monthstatic int
MIN_DAYS_IN_MONTH
The minimum number of days in monthstatic int
MINUTE_MILLIS
static int
MONDAY
Value for Mondaystatic int
MONTHS_IN_YEAR
Number of months in yearstatic DateTimeZone
NEVER_DATE
This value will be set if a job will not run.static long
NEVER_MILLIS
static Long
NEVER_MILLIS_LONG
static String
NEVER_STRING
static long
NOW_MILLIS
This value will be used as the internal representation of "Now", which can be selected in the DateTimePickerControl/CalendarControl.static Long
NOW_MILLIS_LONG
static int
QUARTER_MILLIS
static DateTimeZone
RECALC_DATE
This value will be set if a field should be recalculated.static long
RECALC_MILLIS
static Long
RECALC_MILLIS_LONG
static String
RECALC_STRING
static DateTimeZone
REQUEUE_DATE
This value in milliseconds will be set on aJob.getScheduledStartTime()
if the Job needs to be requeued.static long
REQUEUE_MILLIS
static Long
REQUEUE_MILLIS_LONG
static int
SATURDAY
Value for Saturdaystatic int
SECOND_MILLIS
static int
SUNDAY
Value for Sundaystatic int
THREE_MINUTES_MILLIS
static int
THURSDAY
Value for Thursdaystatic int
TUESDAY
Value for Tuesdaystatic int
WEDNESDAY
Value for Wednesdaystatic int
WEEKEND
Wildcard for weekends (Saturday and Sunday).static int
WORK_DAYS_IN_WEEK
Number of work days in a weekstatic int
WORKDAY
Wildcard for a single day from Monday till Fridaystatic int
WORKWEEK
Wildcard for quintents (Monday,…,Friday).
-
Constructor Summary
Constructors Constructor Description DateTimeZone()
DateTimeZone(int year, int monthZeroBased, int day, int hour, int minute, int second, int milli)
DateTimeZone(long utcMillis)
DateTimeZone(DateTimeZone createCopyFrom)
DateTimeZone(TimeZone timeZone)
DateTimeZone(TimeZone timeZone, int year, int monthZeroBased, int day, int hour, int minute, int second, int milli)
DateTimeZone(TimeZone timeZone, long utcMillis)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int addWhat, int value)
See Calendar.add(int,int)void
add(int addWhat, long value)
When adding milliseconds, you may want to add more than MAXINT.void
add(int amount, TimeUnit timeUnit)
void
add(long amount, TimeUnit timeUnit)
When adding milliseconds, you may want to add more than MAXINT.boolean
after(DateTimeZone moment)
boolean
before(DateTimeZone moment)
int
compareTo(DateTimeZone aDateTimeZone)
int
daysBetween(DateTimeZone other)
static DateTimeZone
decodePLSQLDate(String timeStamp)
Constructs a DateTimeZone from a representation like: 1999.03.01 1999.03.01 00:00:00 1999.03.01 00:00:00 GMTboolean
equals(Object otherObject)
Checks if twoDateTimeZone
objects refer to the same moment in time and to the same time zone.DateTimeZone
expression(String expression)
Applytime expression
expression to this date returning a new DateTimeZone with the modified date.static DateTimeZone
expressionNow(String expression)
Applytime expression
expression to the current time.static String
formatDuration(long duration)
Format a duration using the default format string: "|1 week, |# weeks, |1 day, |# days, |#|:#|:#|.#|".static String
formatDuration(long duration, String format)
Format a duration using the specified format string.static DateTimeZone
fromXSDDateTime(String dateString)
int
get(int getWhat)
See Calendar.get(int)int
get(TemporalField newField)
Calendar
getCalendar()
Return aCalendar
representing the internal state of this DateTimeZone.int
getDayOfMonth()
Return the current day of the month, the first day of the month has a value of one.int
getDayOfWeek()
int
getDayOfYear()
Return the current day of the year, the first day of the year has a value of one.int
getDaysThisMonth()
Returns the last date of this monthstatic TimeZone
getDefaultTimeZone()
Get the default TimeZone.static DateTimeZone
getHighDate()
Returns the highest date we operate withint
getHour()
Return the current hour of the day, this has a range of 0-23.long
getLong(TemporalField newField)
static long
getLookAheadUntil(long from)
static DateTimeZone
getLookAheadUntil(DateTimeZone from)
Returns the 2-years interval within which we compute the time windows.static DateTimeZone
getLowDate()
Returns the lowest date we operate withint
getMillisecond()
Return the current millisecond of the second, this has a range of 0-999.int
getMinute()
Return the current minute of the hour, this has a range of 0-59int
getMonth()
Return the current month of the year, January has a value of zero.int
getSecond()
Return the current second of the minute, this has a range of 0-60 to accommodate for leap seconds.TimeZone
getTimeZone()
static Comparator<DateTimeZone>
getUTCComparator()
long
getUTCMilliSecs()
int
getYear()
The current year.void
goToNextDayOfWeek(int weekday)
Skips to the same time of the next weekday providedint
hashCode()
boolean
isLastDayInMonth()
Is this date the last day of that month?static boolean
isLastDayInMonthNow()
Is it currently the last day of the month?boolean
isLenient()
Tells whether date/time interpretation is to be lenient.boolean
isSupported(TemporalField newField)
boolean
isSupported(TemporalUnit newUnit)
boolean
isWeekend()
boolean
isWorkday()
static DateTimeZone
nowPlusOffset(int amount, TimeUnit timeUnit)
static DateTimeZone
parse(String string, String format)
Parse the string into a date according to the specified Simple Date Format, using the default TimeZone.static DateTimeZone
parse(String string, String format, Locale locale)
Parse the string into a date according to the specified Simple Date Format, using the default TimeZone.static DateTimeZone
parse(TimeZone timezone, String string, String format)
Parse the string into a date according to the specified Simple Date Format.static DateTimeZone
parse(TimeZone timezone, String string, String format, Locale locale)
Parse the string into a date according to the specified Simple Date Format.DateTimeZone
plus(long newAmountToAdd, TemporalUnit newUnit)
DateTimeZone
plus(TemporalAmount newAmountToAdd)
void
set(int setWhat, int value)
See Calendar.set(int,int)void
set(int year, int monthZeroBased, int day, int hour, int minute, int second, int milli)
void
set(int year, int monthZeroBased, int day, int hour, int minute, int second, int milli, TimeZone tz)
void
set(DateTimeZone toCopyFrom)
Sets this DateTimeZone from another DateTimeZonevoid
set(TimeZone timeZone, long utcMilliSecs)
void
setLenient(boolean lenient)
Set the lenient flag, @see Calendar#setLenient(boolean) for more information.void
setNow()
void
setTimeZone(TimeZone timeZone)
void
setUTCMilliSecs(long utcMilliSecs)
void
setYear(int year)
Sets the year.void
smartSetTimeOfDay(int hour, int minute, int second, int milli)
smartSetTimeOfDay should set the 'time-of-day' part to the given values, but if these values are positioned at a 'hole' it should set the time_of_day to the earliest time AFTER the hole.String
toFormattedString(String format)
Format the date according to the specified Simple Date Format.String
toFormattedString(String format, Locale locale)
Format the date according to the specified Simple Date Format.String
toHHMMSSString()
This time formatted HHMMSSLocalDate
toLocalDate()
Convert this DateTimeZone to java's LocalDate.LocalDateTime
toLocalDateTime()
Convert this DateTimeZone to java's LocalDateTimeLocalTime
toLocalTime()
Convert this DateTimeZone to java's LocalTime.String
toString()
A string representation of this timestamp, including ms and time zoneString
toUTCString()
A string representation of this timestamp, converted to UTCString
toYYYYMMDDString()
This date formatted YYYYMMDDZonedDateTime
toZonedDateTime()
Convert this DateTimeZone to java's ZonedDateTimevoid
truncateDay()
Truncate to the beginning of the last day.void
truncateHour()
Truncate to the last hour.void
truncateMinute()
Truncate to the last minute.void
truncateMonth()
Truncate to the beginning of the last month.void
truncateSecond()
Truncate to the last second.void
truncateYear()
Truncate to the beginning of the last year.long
until(Temporal newEndExclusive, TemporalUnit newUnit)
boolean
utcEquals(Object aDateTimeZone)
Checks if twoDateTimeZone
objects refer to the same moment in time, even in different time zonesstatic DateTimeZone
valueOf(String str)
Parse our variation on ISO-8601 dates (YYYY/MM/DD HH:MM:SS,FFF ZZZ) as well as real ISO-8601 timestamps as well as Microsoft's interpretation (that doesn't adhere to ISO-31, and thus uses .)static DateTimeZone
valueOf(TimeZone timeZone, String str)
static String
weekdayJavaToEnglish(int weekdayInJava)
Spells out a DateTimeZone/Calendar weekdaystatic int
weekdayJavaToOracle(int weekdayInJava)
Converts Java representation of a weekday (Sunday = 1, ..) to Oracle (Monday = 1)static int
weekdayOracleToJava(int weekdayInOracle)
Converts Oracle representation of a weekday (Monday = 1, .., Sunday = 7) to Java (Sunday = 1, .., Saturday = 7)DateTimeZone
with(TemporalField newField, long newValue)
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.time.temporal.TemporalAccessor
query, range
-
-
-
-
Field Detail
-
HIGHEST_SPECIAL_DATE_TIME_ZONE
public static final DateTimeZone HIGHEST_SPECIAL_DATE_TIME_ZONE
The dates before this should not be considered normal date values.
-
HIGHEST_SPECIAL_DATE_TIME_ZONE_MILLIS
public static final long HIGHEST_SPECIAL_DATE_TIME_ZONE_MILLIS
-
REQUEUE_MILLIS
public static final long REQUEUE_MILLIS
- See Also:
- Constant Field Values
-
REQUEUE_DATE
public static final DateTimeZone REQUEUE_DATE
This value in milliseconds will be set on aJob.getScheduledStartTime()
if the Job needs to be requeued. This date is later thanRECALC_DATE
, but earlier than any date that a user can set forJob.setRequestedStartTime(DateTimeZone)
. Note: only set milliseconds, otherwise the time zone of the job will be reset to GMT. Comparing for this special date must be done on milliseconds.
-
REQUEUE_MILLIS_LONG
public static final Long REQUEUE_MILLIS_LONG
-
NOW_MILLIS
public static final long NOW_MILLIS
This value will be used as the internal representation of "Now", which can be selected in the DateTimePickerControl/CalendarControl.- See Also:
- Constant Field Values
-
NOW_MILLIS_LONG
public static final Long NOW_MILLIS_LONG
-
RECALC_MILLIS
public static final long RECALC_MILLIS
- See Also:
- Constant Field Values
-
RECALC_DATE
public static final DateTimeZone RECALC_DATE
This value will be set if a field should be recalculated. This is the earliest date that a DateTimeZone can take. Note: only set milliseconds, otherwise the time zone of the job will be reset to GMT. Comparing for this special date must be done on milliseconds.
-
RECALC_MILLIS_LONG
public static final Long RECALC_MILLIS_LONG
-
NEVER_MILLIS
public static final long NEVER_MILLIS
- See Also:
- Constant Field Values
-
NEVER_DATE
public static final DateTimeZone NEVER_DATE
This value will be set if a job will not run. This is the latest date that a DateTimeZone can take. Note: only set milliseconds, otherwise the time zone of the job will be reset to GMT. Comparing for this special date must be done on milliseconds.
-
NEVER_MILLIS_LONG
public static final Long NEVER_MILLIS_LONG
-
MONTHS_IN_YEAR
public static final int MONTHS_IN_YEAR
Number of months in year- See Also:
- Constant Field Values
-
DAYS_IN_WEEK
public static final int DAYS_IN_WEEK
Number of days in week- See Also:
- Constant Field Values
-
WORK_DAYS_IN_WEEK
public static final int WORK_DAYS_IN_WEEK
Number of work days in a week- See Also:
- Constant Field Values
-
HOURS_IN_DAY
public static final int HOURS_IN_DAY
Number of hours in day- See Also:
- Constant Field Values
-
MIN_DAYS_IN_MONTH
public static final int MIN_DAYS_IN_MONTH
The minimum number of days in month- See Also:
- Constant Field Values
-
MAX_DAYS_IN_MONTH
public static final int MAX_DAYS_IN_MONTH
The maximum number of days in month- See Also:
- Constant Field Values
-
MAX_WORK_DAYS_IN_MONTH
public static final int MAX_WORK_DAYS_IN_MONTH
The maximum number of workdays in month- See Also:
- Constant Field Values
-
MAX_WEEKS_IN_MONTH
public static final int MAX_WEEKS_IN_MONTH
The maximum number of (partial) weeks in month- See Also:
- Constant Field Values
-
SUNDAY
public static final int SUNDAY
Value for Sunday- See Also:
- Constant Field Values
-
MONDAY
public static final int MONDAY
Value for Monday- See Also:
- Constant Field Values
-
TUESDAY
public static final int TUESDAY
Value for Tuesday- See Also:
- Constant Field Values
-
WEDNESDAY
public static final int WEDNESDAY
Value for Wednesday- See Also:
- Constant Field Values
-
THURSDAY
public static final int THURSDAY
Value for Thursday- See Also:
- Constant Field Values
-
FRIDAY
public static final int FRIDAY
Value for Friday- See Also:
- Constant Field Values
-
SATURDAY
public static final int SATURDAY
Value for Saturday- See Also:
- Constant Field Values
-
WORKDAY
public static final int WORKDAY
Wildcard for a single day from Monday till Friday- See Also:
- Constant Field Values
-
WEEKEND
public static final int WEEKEND
Wildcard for weekends (Saturday and Sunday). EachWEEKEND
consists of twoANYDAY
s.- See Also:
- Constant Field Values
-
WORKWEEK
public static final int WORKWEEK
Wildcard for quintents (Monday,…,Friday). EachWORKWEEK
consists of 5WORKDAY
s.- See Also:
- Constant Field Values
-
ANYDAY
public static final int ANYDAY
Wildcard for any single day.- See Also:
- Constant Field Values
-
LASTANYDAY
public static final int LASTANYDAY
A special value meaning 'the last day of the month'. It has nothing to do with the day number, while it is always greater than that.- See Also:
- Constant Field Values
-
LASTWORKDAY
public static final int LASTWORKDAY
A special value meaning 'the last working day of the month'. It has nothing to do with the day number, while it is always greater than that.- See Also:
- Constant Field Values
-
MAX_RECURRENCE_INTERVAL
public static final int MAX_RECURRENCE_INTERVAL
The maximum size of an interval that can be specified in a recurrence- See Also:
- Constant Field Values
-
HOUR_MILLIS
public static final int HOUR_MILLIS
Number of milliseconds in an hour.- See Also:
- Constant Field Values
-
DAY_MILLIS
public static final int DAY_MILLIS
Number of milliseconds in an day.- See Also:
- Constant Field Values
-
SECOND_MILLIS
public static final int SECOND_MILLIS
- See Also:
- Constant Field Values
-
MINUTE_MILLIS
public static final int MINUTE_MILLIS
- See Also:
- Constant Field Values
-
THREE_MINUTES_MILLIS
public static final int THREE_MINUTES_MILLIS
- See Also:
- Constant Field Values
-
FIVE_MINUTES_MILLIS
public static final int FIVE_MINUTES_MILLIS
- See Also:
- Constant Field Values
-
QUARTER_MILLIS
public static final int QUARTER_MILLIS
- See Also:
- Constant Field Values
-
NEVER_STRING
public static final String NEVER_STRING
- See Also:
- Constant Field Values
-
RECALC_STRING
public static final String RECALC_STRING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DateTimeZone
public DateTimeZone()
-
DateTimeZone
public DateTimeZone(TimeZone timeZone, long utcMillis)
-
DateTimeZone
public DateTimeZone(long utcMillis)
-
DateTimeZone
public DateTimeZone(TimeZone timeZone)
-
DateTimeZone
public DateTimeZone(TimeZone timeZone, int year, int monthZeroBased, int day, int hour, int minute, int second, int milli)
-
DateTimeZone
public DateTimeZone(int year, int monthZeroBased, int day, int hour, int minute, int second, int milli)
-
DateTimeZone
public DateTimeZone(DateTimeZone createCopyFrom)
-
-
Method Detail
-
nowPlusOffset
public static DateTimeZone nowPlusOffset(int amount, TimeUnit timeUnit)
-
add
public void add(int amount, TimeUnit timeUnit)
-
add
public void add(long amount, TimeUnit timeUnit)
When adding milliseconds, you may want to add more than MAXINT. See Calendar.add(int, TimeUnit)- Parameters:
amount
- of elements (long) to addtimeUnit
- TimeUnit to add
-
getLowDate
public static DateTimeZone getLowDate()
Returns the lowest date we operate with- Returns:
- the lowest date we operate with
-
getHighDate
public static DateTimeZone getHighDate()
Returns the highest date we operate with- Returns:
- the highest date we operate with
-
getTimeZone
public TimeZone getTimeZone()
-
setTimeZone
public void setTimeZone(TimeZone timeZone)
-
getUTCMilliSecs
public long getUTCMilliSecs()
-
setUTCMilliSecs
public void setUTCMilliSecs(long utcMilliSecs)
-
set
public void set(TimeZone timeZone, long utcMilliSecs)
-
setYear
public void setYear(int year)
Sets the year. It is not the same as Calendar.set(Calendar.YEAR,year) because it does not support the batch execution of multipleset
-s- Parameters:
year
- the year to be set
-
getDaysThisMonth
public int getDaysThisMonth()
Returns the last date of this month- Returns:
- the last date of this month
-
truncateSecond
public void truncateSecond()
Truncate to the last second. That is, set the time of this object to be that of the beginning of the second, removing the millisecond component.
-
truncateMinute
public void truncateMinute()
Truncate to the last minute. That is, set the time of this object to be that of the beginning of the minute, removing second and millisecond components.
-
truncateHour
public void truncateHour()
Truncate to the last hour. That is, set the time of this object to be that of the beginning of the hour, removing minute, second and millisecond components.
-
truncateDay
public void truncateDay()
Truncate to the beginning of the last day. That is, set the time of this object to be that of the beginning of the day, removing hour, minute, second and millisecond components.
-
truncateMonth
public void truncateMonth()
Truncate to the beginning of the last month. That is, set the time of this object to be that of the beginning of the month, removing day, hour, minute, second and millisecond components.
-
truncateYear
public void truncateYear()
Truncate to the beginning of the last year. That is, set the time of this object to be that of the beginning of the year, removing month, day, hour, minute, second and millisecond components.
-
set
public void set(DateTimeZone toCopyFrom)
Sets this DateTimeZone from another DateTimeZone- Parameters:
toCopyFrom
- to copy from
-
set
public void set(int year, int monthZeroBased, int day, int hour, int minute, int second, int milli)
-
set
public void set(int year, int monthZeroBased, int day, int hour, int minute, int second, int milli, TimeZone tz)
-
add
public void add(int addWhat, int value)
See Calendar.add(int,int)- Parameters:
addWhat
- date element (int) to addvalue
- amount of elements (int) to add
-
add
public void add(int addWhat, long value)
When adding milliseconds, you may want to add more than MAXINT. See Calendar.add(int,int)- Parameters:
addWhat
- date element (int), i.e. Calendar field to addvalue
- amount of elements (int) to add
-
goToNextDayOfWeek
public void goToNextDayOfWeek(int weekday)
Skips to the same time of the next weekday provided- Parameters:
weekday
- the weekday Calendar.SUNDAY..Calendar.SATURDAY to skip to
-
set
public void set(int setWhat, int value)
See Calendar.set(int,int)- Parameters:
setWhat
- date element (int) to addvalue
- amount of elements (int) to add
-
getYear
public int getYear()
The current year.- Returns:
- current year
-
getMonth
public int getMonth()
Return the current month of the year, January has a value of zero.- Returns:
- zero-based month
-
getDayOfYear
public int getDayOfYear()
Return the current day of the year, the first day of the year has a value of one.- Returns:
- day of year
-
getDayOfMonth
public int getDayOfMonth()
Return the current day of the month, the first day of the month has a value of one.- Returns:
- day of month
-
getDayOfWeek
public int getDayOfWeek()
Return the current day of the week, returns one ofSUNDAY
,MONDAY
,TUESDAY
,WEDNESDAY
,THURSDAY
,FRIDAY
,SATURDAY
.- Returns:
- day of week
-
getHour
public int getHour()
Return the current hour of the day, this has a range of 0-23.- Returns:
- the current hour of the day
-
getMinute
public int getMinute()
Return the current minute of the hour, this has a range of 0-59- Returns:
- the current minute of the hour
-
getSecond
public int getSecond()
Return the current second of the minute, this has a range of 0-60 to accommodate for leap seconds.- Returns:
- the current second of the minute
-
getMillisecond
public int getMillisecond()
Return the current millisecond of the second, this has a range of 0-999.- Returns:
- the current millisecond of the second
-
get
public int get(int getWhat)
See Calendar.get(int)- Parameters:
getWhat
- calendar element to retrieve- Returns:
- Calendar.get(int)
-
before
public boolean before(DateTimeZone moment)
-
after
public boolean after(DateTimeZone moment)
-
utcEquals
public boolean utcEquals(Object aDateTimeZone)
Checks if twoDateTimeZone
objects refer to the same moment in time, even in different time zones- Parameters:
aDateTimeZone
- to compare with- Returns:
- true if both represent the same moment
-
equals
public boolean equals(Object otherObject)
Checks if twoDateTimeZone
objects refer to the same moment in time and to the same time zone.
-
weekdayJavaToOracle
public static int weekdayJavaToOracle(int weekdayInJava) throws DateTimeConstantOutOfBoundsException
Converts Java representation of a weekday (Sunday = 1, ..) to Oracle (Monday = 1)- Parameters:
weekdayInJava
- a constant Calendar.SUNDAY,...,Calendar.SATURDAY- Returns:
- 1 (Monday) to 7 (Sunday)
- Throws:
DateTimeConstantOutOfBoundsException
- if weekdayInJava is not in the range 1..7
-
weekdayJavaToEnglish
public static String weekdayJavaToEnglish(int weekdayInJava) throws DateTimeConstantOutOfBoundsException
Spells out a DateTimeZone/Calendar weekday- Parameters:
weekdayInJava
- a constant Calendar.SUNDAY,...,Calendar.SATURDAY, DateTimeZone.WEEKEND, DateTimeZone.WORKDAY, DateTimeZone.ANYDAY- Returns:
- a word in English
- Throws:
DateTimeConstantOutOfBoundsException
- if weekdayInJava is not in the range 1..7
-
weekdayOracleToJava
public static int weekdayOracleToJava(int weekdayInOracle) throws DateTimeConstantOutOfBoundsException
Converts Oracle representation of a weekday (Monday = 1, .., Sunday = 7) to Java (Sunday = 1, .., Saturday = 7)- Parameters:
weekdayInOracle
- Oracle representation of a weekday (Monday = 1, .., Sunday = 7)- Returns:
- a constant Calendar.SUNDAY,...,Calendar.SATURDAY
- Throws:
DateTimeConstantOutOfBoundsException
- if weekdayInJava is not in the range 1..7
-
toUTCString
public String toUTCString()
A string representation of this timestamp, converted to UTC- Returns:
- string representation of this timestamp
-
toString
public String toString()
A string representation of this timestamp, including ms and time zone
-
valueOf
public static DateTimeZone valueOf(String str)
Parse our variation on ISO-8601 dates (YYYY/MM/DD HH:MM:SS,FFF ZZZ) as well as real ISO-8601 timestamps as well as Microsoft's interpretation (that doesn't adhere to ISO-31, and thus uses .)- Parameters:
str
- String representation of timestamp.- Returns:
- a timestamp.
-
valueOf
public static DateTimeZone valueOf(TimeZone timeZone, String str)
-
toYYYYMMDDString
public String toYYYYMMDDString()
This date formatted YYYYMMDD- Returns:
- string representation of this date
-
toHHMMSSString
public String toHHMMSSString()
This time formatted HHMMSS- Returns:
- string representation of this time
-
decodePLSQLDate
public static DateTimeZone decodePLSQLDate(String timeStamp)
Constructs a DateTimeZone from a representation like:- 1999.03.01
- 1999.03.01 00:00:00
- 1999.03.01 00:00:00 GMT
- Parameters:
timeStamp
- string with timestamp, e.g. 1999.03.01 00:00:00 GMT- Returns:
DateTimeZone
-
getLookAheadUntil
public static DateTimeZone getLookAheadUntil(DateTimeZone from)
Returns the 2-years interval within which we compute the time windows. This is the central point for computing this interval, it is also used in tests.- Parameters:
from
- The moment to start counting from- Returns:
- cut-off timestamp, a new DateTimeZone, that is not used elsewhere
-
getLookAheadUntil
public static long getLookAheadUntil(long from)
-
setNow
public void setNow()
-
smartSetTimeOfDay
public void smartSetTimeOfDay(int hour, int minute, int second, int milli)
smartSetTimeOfDay should set the 'time-of-day' part to the given values, but if these values are positioned at a 'hole' it should set the time_of_day to the earliest time AFTER the hole. Furthermore if we set the time in an overlap, the Calendar implementation takes the LAST alternative and we want the first alternative There are some implicit assumptions here:- holes and overlaps start and end at a full minute
- holes and overlaps do not pass day boundaries
- holes and overlaps do not start at midnight
- no day has more than one hole or overlap
- use getTimeZone() and try to derive the information you need from that (probably not much easier)
- use another set of base classes (http://joda-time.sourceforge.net/index.html) (not sure if this set really tackles the problem)
- write our own set of base-classes (copy the source of GregorianCalendar to start)
- Parameters:
hour
- hourminute
- minutesecond
- secondmilli
- millisecond
-
getCalendar
public Calendar getCalendar()
Return aCalendar
representing the internal state of this DateTimeZone. This is useful for printing this DateTimeZone usingDateFormat.setCalendar(Calendar)
.- Returns:
- a
Calendar
representing the internal state of this DateTimeZone
-
daysBetween
public int daysBetween(DateTimeZone other)
- Parameters:
other
-- Returns:
- the number of days to get from this date to the other date
-
getUTCComparator
public static Comparator<DateTimeZone> getUTCComparator()
-
getDefaultTimeZone
public static TimeZone getDefaultTimeZone()
Get the default TimeZone.- Returns:
- the default TimeZone.
-
expression
public DateTimeZone expression(String expression)
Applytime expression
expression to this date returning a new DateTimeZone with the modified date.- Parameters:
expression
- the time expression to apply.- Returns:
- the new DateTimeZone modified by the expression
-
expressionNow
public static DateTimeZone expressionNow(String expression)
Applytime expression
expression to the current time.- Parameters:
expression
- the time expression to apply.- Returns:
- the modified DateTimeZone.
-
toFormattedString
public String toFormattedString(String format)
Format the date according to the specified Simple Date Format.- Parameters:
format
- the format expression- Returns:
- the formatted date
- Throws:
com.redwood.scheduler.api.exception.InvalidFormatException
- if the given format is nullIllegalArgumentException
- if the given format is invalidcom.redwood.scheduler.api.exception.InvalidDateFormatUnknownLocale
- if the given format contains a unknown locale id
-
toFormattedString
public String toFormattedString(String format, Locale locale)
Format the date according to the specified Simple Date Format.Additional format field 'i' for the Olson-name of the time zone is supported.
- Parameters:
format
- the format expressionlocale
- the locale to use for formatting. When no locale is specified, the default locale will be used.- Returns:
- the formatted date
- Throws:
com.redwood.scheduler.api.exception.InvalidFormatException
- if the given format is nullIllegalArgumentException
- if the given format is invalidcom.redwood.scheduler.api.exception.InvalidDateFormatUnknownLocale
- if the given format contains a unknown locale id
-
toLocalDate
public LocalDate toLocalDate()
Convert this DateTimeZone to java's LocalDate.- Returns:
- LocalDate
-
toLocalTime
public LocalTime toLocalTime()
Convert this DateTimeZone to java's LocalTime.- Returns:
- LocalTime
-
toLocalDateTime
public LocalDateTime toLocalDateTime()
Convert this DateTimeZone to java's LocalDateTime- Returns:
- LocalDateTime
-
toZonedDateTime
public ZonedDateTime toZonedDateTime()
Convert this DateTimeZone to java's ZonedDateTime- Returns:
- ZonedDateTime
-
parse
public static DateTimeZone parse(TimeZone timezone, String string, String format) throws ParseException
Parse the string into a date according to the specified Simple Date Format.Additional format fields are supported, such as locale {en} and TimeZoneId 'i'
- Parameters:
timezone
- the TimeZone to usestring
- the string to parseformat
- the date format expression- Returns:
- the resulting DateTimeZone
- Throws:
com.redwood.scheduler.api.exception.InvalidFormatException
- if the given format is nullIllegalArgumentException
- if the given format is invalidcom.redwood.scheduler.api.exception.InvalidDateFormatUnknownLocale
- if the given format contains a unknown locale idParseException
- if the parsing fails
-
parse
public static DateTimeZone parse(TimeZone timezone, String string, String format, Locale locale) throws ParseException
Parse the string into a date according to the specified Simple Date Format.Additional format field 'i' for the Olson-name of the time zone is supported.
- Parameters:
timezone
- the TimeZone to usestring
- the string to parseformat
- the date format expressionlocale
- the locale to use for formatting. When no locale is specified, the default locale will be used.- Returns:
- the resulting DateTimeZone
- Throws:
com.redwood.scheduler.api.exception.InvalidFormatException
- if the given format is nullIllegalArgumentException
- if the given format is invalidcom.redwood.scheduler.api.exception.InvalidDateFormatUnknownLocale
- if the given format contains a unknown locale idParseException
- if the parsing fails
-
parse
public static DateTimeZone parse(String string, String format) throws ParseException
Parse the string into a date according to the specified Simple Date Format, using the default TimeZone.Additional format fields are supported, such as locale {en} and TimeZoneId 'i'
- Parameters:
string
- the string to parseformat
- the date format expression- Returns:
- the resulting DateTimeZone
- Throws:
com.redwood.scheduler.api.exception.InvalidFormatException
- if the given format is nullIllegalArgumentException
- if the given format is invalidcom.redwood.scheduler.api.exception.InvalidDateFormatUnknownLocale
- if the given format contains a unknown locale idParseException
- if the parsing fails
-
parse
public static DateTimeZone parse(String string, String format, Locale locale) throws ParseException
Parse the string into a date according to the specified Simple Date Format, using the default TimeZone.Additional format field 'i' for the Olson-name of the time zone is supported.
- Parameters:
string
- the string to parseformat
- the date format expressionlocale
- the locale to use for formatting. When no locale is specified, the default locale will be used.- Returns:
- the resulting DateTimeZone
- Throws:
com.redwood.scheduler.api.exception.InvalidFormatException
- if the given format is nullIllegalArgumentException
- if the given format is invalidcom.redwood.scheduler.api.exception.InvalidDateFormatUnknownLocale
- if the given format contains a unknown locale idParseException
- if the parsing fails
-
isLastDayInMonthNow
public static boolean isLastDayInMonthNow()
Is it currently the last day of the month?- Returns:
- true if it is the last day of the month, otherwise false.
-
isLastDayInMonth
public boolean isLastDayInMonth()
Is this date the last day of that month?- Returns:
- true if it is the last day of the month, otherwise false.
-
fromXSDDateTime
public static DateTimeZone fromXSDDateTime(String dateString) throws ParseException
- Throws:
ParseException
-
formatDuration
public static String formatDuration(long duration)
Format a duration using the default format string: "|1 week, |# weeks, |1 day, |# days, |#|:#|:#|.#|".- Parameters:
duration
- the duration in milliseconds- Returns:
- the formatted string
-
formatDuration
public static String formatDuration(long duration, String format)
Format a duration using the specified format string. The format starts and ends with | and is separated by |. There are 8 elements, each controls how to format part of the string:- 1 week
- 2 weeks or more, # is replaced with the number of weeks.
- 1 day
- 2 days or more, # is replaced with the number of days.
- Hours, # is replaced with the two digit number of hours.
- Minutes, # is replaced with the two digit number of minutes.
- Seconds, # is replaced with the two digit number of seconds.
- Milliseconds, # is replaced with the two digit number of milliseconds.
- Parameters:
duration
- the duration in millisecondsformat
- the format to use.- Returns:
- the formatted duration.
-
compareTo
public int compareTo(DateTimeZone aDateTimeZone)
- Specified by:
compareTo
in interfaceComparable<DateTimeZone>
-
setLenient
public void setLenient(boolean lenient)
Set the lenient flag, @see Calendar#setLenient(boolean) for more information. It is recommended not to pass 'strict' dates through to API calls (ie. reset this flag before making an API call) as behavior may differ for strict dates.- Parameters:
lenient
- the new value for the lenient flag.- See Also:
isLenient()
-
isLenient
public boolean isLenient()
Tells whether date/time interpretation is to be lenient.- Returns:
- true if the interpretation mode of this calendar is lenient; false otherwise.
- See Also:
setLenient(boolean)
-
isSupported
public boolean isSupported(TemporalField newField)
- Specified by:
isSupported
in interfaceTemporalAccessor
-
isSupported
public boolean isSupported(TemporalUnit newUnit)
- Specified by:
isSupported
in interfaceTemporal
-
get
public int get(TemporalField newField)
- Specified by:
get
in interfaceTemporalAccessor
-
getLong
public long getLong(TemporalField newField)
- Specified by:
getLong
in interfaceTemporalAccessor
-
with
public DateTimeZone with(TemporalField newField, long newValue)
-
plus
public DateTimeZone plus(TemporalAmount newAmountToAdd)
-
plus
public DateTimeZone plus(long newAmountToAdd, TemporalUnit newUnit)
-
until
public long until(Temporal newEndExclusive, TemporalUnit newUnit)
-
-