Skip navigation links


COM.FutureTense.Util
Class TimePattern

java.lang.Object
  extended by COM.FutureTense.Util.TimePattern

All Implemented Interfaces:
java.io.Serializable

public class TimePattern
extends java.lang.Object
implements java.io.Serializable

This class represents a scheduled time, using a syntax similar to the UNIX 'cron' syntax. The format is described as follows:

hh:mm:ss W/DD/MM
hh: 0 - 23
mm: 0 - 59
ss: 0 - 59
W (day of the week): 0 - 6 with 0 = Sunday.
DD (day of the month): 1 - 31
MM (month): 1 - 12

Each of these fields may be either an asterisk (meaning all legal values) or a list of elements separated by commas. An element is either a number or two numbers separated by a minus sign indicating an inclusive range. For example, 2, 5 - 7:0:0 5/*\/* means the event is triggered at 2 AM, 5AM, 6 AM and 7 AM every Friday. The specification of days can be made by two fields: day of the month (DD) and day of the week (W). If both are specified, both take effect. For example, 1:0:0 1/15/* means the event is triggered at 1 AM every Monday, as well as on the fifteenth of each month. To specify days by only one field, set the other field to *.

This class is immutable, thread-safe, and serializable.

See Also:
Serialized Form

Field Summary
static java.lang.String IMMEDIATE
          TimePattern string representing a pattern that always matches
static TimePattern IMMEDIATE_TIMEPATTERN
          TimePattern that matches every instant in time
static java.lang.String NEVER
          TimePattern string representing a pattern that will never be matched.
static TimePattern NEVER_TIMEPATTERN
          TimePattern that never matches any instant in time
static java.lang.String sImmediate
          Deprecated. use IMMEDIATE
static java.lang.String sNever
          Deprecated. use NEVER

 

Constructor Summary
TimePattern(java.lang.String pattern)
          Deprecated. use valueOf(String) instead

 

Method Summary
static TimePattern getTimePattern(java.lang.String tp)
          Deprecated. (use valueOf(String) instead)
 boolean matches(java.util.Calendar time)
          Determines if this TimePattern has had a match between the specified time, and right now.
 boolean never()
          Return whether this timepattern is designed to never match
 java.util.Calendar nextMatch(java.util.Calendar rangeStart, java.util.Calendar rangeEnd)
          Get the next match for this TimePattern between the two dates passed in
 java.util.Date nextMatch(java.util.Date rangeStart, java.util.Date rangeEnd)
          Get the next match for this TimePattern between the two dates passed in
 boolean now()
          Return whether or not this TimePattern matches every instant in time.
 java.lang.String toString()
          Return the string representation of a time pattern
static TimePattern valueOf(java.lang.String pattern)
          Return an instance of a TimePattern object given the input string specified.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Field Detail

NEVER

public static final java.lang.String NEVER
TimePattern string representing a pattern that will never be matched.
See Also:
Constant Field Values

IMMEDIATE

public static final java.lang.String IMMEDIATE
TimePattern string representing a pattern that always matches
See Also:
Constant Field Values

sNever

public static final java.lang.String sNever
Deprecated. use NEVER
See Also:
Constant Field Values

sImmediate

public static final java.lang.String sImmediate
Deprecated. use IMMEDIATE
See Also:
Constant Field Values

NEVER_TIMEPATTERN

public static final TimePattern NEVER_TIMEPATTERN
TimePattern that never matches any instant in time

IMMEDIATE_TIMEPATTERN

public static final TimePattern IMMEDIATE_TIMEPATTERN
TimePattern that matches every instant in time

Constructor Detail

TimePattern

public TimePattern(java.lang.String pattern)
Deprecated. use valueOf(String) instead
Construct a TimePattern from a well formed string. No error checking done
Parameters:
pattern - time pattern string
Throws:
java.lang.IllegalArgumentException - if the TimePattern is invalid

Method Detail

valueOf

public static final TimePattern valueOf(java.lang.String pattern)
Return an instance of a TimePattern object given the input string specified.
Parameters:
pattern - TimePattern string
Returns:
TimePattern object
Throws:
java.lang.IllegalArgumentException - if the pattern specified is now well-formed.
Since:
6.0

getTimePattern

public static final TimePattern getTimePattern(java.lang.String tp)
Deprecated. (use valueOf(String) instead)
Create a timepattern that (1) never expires (2) expires now or (3) a regular old time pattern, using the input string
Parameters:
tp - time pattern string
Returns:
TimePattern, MAY BE NULL
Throws:
java.lang.IllegalArgumentException - on invalid data

toString

public java.lang.String toString()
Return the string representation of a time pattern
Overrides:
toString in class java.lang.Object

never

public boolean never()
Return whether this timepattern is designed to never match
Returns:
true if no match will ever be found, false if it is possible to match this TimePattern to an instant in time

now

public boolean now()
Return whether or not this TimePattern matches every instant in time.
Returns:
true if the TimePattern matches every instant in time, false if it matches only specific instants in time.

matches

public boolean matches(java.util.Calendar time)
Determines if this TimePattern has had a match between the specified time, and right now.
Parameters:
time - The last time this TimePattern had a match.
Returns:
true if this TimePattern has had a match between time and now, false otherwise.

nextMatch

public java.util.Date nextMatch(java.util.Date rangeStart,
                                java.util.Date rangeEnd)
Get the next match for this TimePattern between the two dates passed in
Parameters:
rangeStart - Find the next match after this date
rangeEnd - Find the next match before this match
Returns:
Calendar set to the next matching time in the range specified, or null if no matches exist in the range specified.
Since:
7.0

nextMatch

public java.util.Calendar nextMatch(java.util.Calendar rangeStart,
                                    java.util.Calendar rangeEnd)
Get the next match for this TimePattern between the two dates passed in
Parameters:
rangeStart - Find the next match after this date
rangeEnd - Find the next match before this match
Returns:
Calendar set to the next matching time in the range specified, or null if no matches exist in the range specified.
Since:
6.0

Skip navigation links


Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.