|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.util.DateTimeMonitor
public class DateTimeMonitor
DateTimeMonitor
is a text model that updates itself with the current date
and time at regular intervals. The default interval is one second.
The time zone with which the date format is recreated on deserialization
will be the current local default time zone, not
the time zone in use when the DateTimeMonitor
was serialized.
This makes sense in most applications. Subclasses can change this
explicitly calling
in their private dateTimeFormat.setTimeZone(tz)
readObject()
method.
Name | interval |
Type | long |
Default value | TimeIntervals.ONE_SECOND
|
Short description | update interval |
Description | interval between updates, in milliseconds |
Name | dateTime |
Type | java.util.Calendar |
Default value | a calendar representing the current time |
Short description | the current time |
Description | the current time, as of the last update |
Name | format |
Type | java.text.DateFormat |
Default value | java.text.DateFormat.getDateTimeInstance() |
Short description | format |
Description | date time formatter |
Field Summary | |
---|---|
protected Alarm |
alarm
Internal Alarm , used to update the Date and text at regular intervals. |
protected java.util.Date |
date
The current date, updated at regular intervals. |
protected java.text.DateFormat |
dateTimeFormat
The DateFormat used to format the current date at regular intervals. |
static java.util.TimeZone |
defaultTimeZone
The default time zone. |
static java.lang.String |
RB_KEY
|
Fields inherited from interface com.sas.util.TimeIntervals |
---|
ONE_DAY, ONE_HOUR, ONE_MINUTE, ONE_SECOND, ONE_WEEK |
Constructor Summary | |
---|---|
DateTimeMonitor()
Default constructor. |
|
DateTimeMonitor(java.text.DateFormat dateTimeFormat)
Custom constructor for non- Locale default date format. |
|
DateTimeMonitor(java.text.DateFormat dateTimeFormat,
java.util.Calendar calendar)
Deprecated. the calendar parameter is no longer used. Use DateTimeMonitor(DateFormat) or
DateTimeMonitor(dateTimeFormat, long delay, long interval) |
|
DateTimeMonitor(java.text.DateFormat dateTimeFormat,
java.util.Calendar calendar,
long delay,
long interval)
Deprecated. the calendar parameter is no longer used. Use DateTimeMonitor(dateTimeFormat, long delay, long interval) |
|
DateTimeMonitor(java.text.DateFormat dateTimeFormat,
long delay,
long interval)
Custom constructor for non-Locale default date format. |
|
DateTimeMonitor(int format)
Custom constructor for a default date format and default calendar. |
|
DateTimeMonitor(java.lang.String format)
Custom constructor for default date format |
Method Summary | |
---|---|
void |
fireAlarm(AlarmEvent event)
Handle an AlarmEvent from the internal alarm. |
java.util.Date |
getDateTime()
Return the date/time as it was last monitored. |
protected long |
getDelay()
Return the time delay before the monitor updates. |
static com.sas.beans.ExtendedBeanInfo |
getExtendedBeanInfo()
|
java.text.DateFormat |
getFormat()
Return the format property |
long |
getInterval()
Return the interval at which the monitor updates the date/time and text properties. |
boolean |
isAlarmRunning()
Returns a boolean indicating whether the alarm is running |
protected Alarm |
newAlarm(long delay,
long interval)
|
void |
setFormat(java.text.DateFormat format)
Replace the date/time format. |
void |
setInterval(long interval)
Set the update interval. |
void |
start()
Restart the date/time monitor. |
void |
stop()
Stop the date/time monitor. |
void |
update()
Update the date time monitor after the time interval has expired. |
void |
validateObject()
Validate/initialize the object after deserialization. |
Field Detail |
---|
public static final java.lang.String RB_KEY
protected transient java.text.DateFormat dateTimeFormat
DateFormat
used to format the current date at regular intervals.
protected transient java.util.Date date
protected Alarm alarm
Alarm
, used to update the Date
and text at regular intervals.
public static java.util.TimeZone defaultTimeZone
Constructor Detail |
---|
public DateTimeMonitor()
DateMonitor
object which updates
its text attribute when the date changes, using the
default Locale
specific date format.
public DateTimeMonitor(java.text.DateFormat dateTimeFormat, java.util.Calendar calendar)
DateTimeMonitor(DateFormat)
or
DateTimeMonitor(dateTimeFormat, long delay, long interval)
Locale
default date format and calendar.
dateTimeFormat
- a date format with which the date is rendered.
Note that you probably want to set the timezone on this formatter
with format.setTimeZone(DateTimeMonitor.defaultTimeZone);
before using the dateTimeFormat.calendar
- a calendar with which time values are obtainedpublic DateTimeMonitor(java.text.DateFormat dateTimeFormat)
Locale
default date format.
dateTimeFormat
- a date format with which the date is rendered.
Note that you probably want to set the timezone on this formatter
with format.setTimeZone(DateTimeMonitor.defaultTimeZone);
before using the dateTimeFormat.public DateTimeMonitor(int format)
format
- one of
DateFormat.SHORT
,
DateFormat.MEDIUM
,
DateFormat.LONG
, or
DateFormat.FULL
The current time zone is applied to the format.public DateTimeMonitor(java.text.DateFormat dateTimeFormat, java.util.Calendar calendar, long delay, long interval)
DateTimeMonitor(dateTimeFormat, long delay, long interval)
Locale
default date format and calendar.
dateTimeFormat
- a date format with which the date is rendered.
Note that you probably want to set the timezone on this formatter
with format.setTimeZone(DateTimeMonitor.defaultTimeZone);
before using the dateTimeFormat.calendar
- a calendar with which time values are obtaineddelay
- how much time to delay before starting updates.
if delay == -1, use getDelay()
interval
- how much time to pause between updates.
if interval == -1, use getInterval()
public DateTimeMonitor(java.text.DateFormat dateTimeFormat, long delay, long interval)
dateTimeFormat
- a date format with which the date is rendered.
Note that you probably want to set the timezone on this formatter
with format.setTimeZone(DateTimeMonitor.defaultTimeZone);
before using the dateTimeFormat.delay
- how much time to delay before starting updates.
if delay == -1, use getDelay()
interval
- how much time to pause between updates.
if interval == -1, use getInterval()
public DateTimeMonitor(java.lang.String format)
format
- A format string used to construct a SimpleDateFormat
object which is used to format the date and time.
The default time zone is used.Method Detail |
---|
public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
protected Alarm newAlarm(long delay, long interval)
public java.text.DateFormat getFormat()
public void setFormat(java.text.DateFormat format)
dateTimeFormat
- a date/time format with which the
monitored date/time value is formatted into the
text property.
Note that you probably want to set the timezone on this formatter
with format.setTimeZone(DateTimeMonitor.defaultTimeZone);
before using the dateTimeFormat.protected long getDelay()
DateTimeMonitor.ONE_SECOND
public long getInterval()
public void setInterval(long interval)
interval
- the amount of time between updates,
such as DateTimeMonitor.ONE_SECOND
public java.util.Date getDateTime()
public void fireAlarm(AlarmEvent event)
AlarmEvent
from the internal alarm.
fireAlarm
in interface AlarmListener
event
- the alarm event.public void update()
public void stop()
PropertyChangeEvent
s, until started again.
public void start()
PropertyChangeEvent
s, until stopped.
public boolean isAlarmRunning()
public void validateObject()
validateObject
in interface java.io.ObjectInputValidation
validateObject
in class com.sas.Component
ComponentInterfaceSupport.validateObject(com.sas.ComponentInterface)
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |