public class TimeSelector extends Object
ElementContainer ec timeSelect = new ElementContainer(); String myName = "mytime"; ec.addElement(TimeSelector.getHourSelector(myName)); ec.addElement(TimeSelector.getMinuteSelector(myName)); ec.addElement(TimeSelector.getAMPMSelector(myName));There are also methods which will use attributes to build a complete time selector in the default 12hr format (eg HH:MM am/pm):
TimeSelector ts = new TimeSelector(myName); timeSelect = ts.ecsOutput();Minutes/Seconds are by default rounded to the nearest 5 units although this can be easily changed. 24hr TimeSelectors can also be produced. The following example creates a full precision TimeSelector (eg HH:MM:SS):
TimeSelector ts = new TimeSelector(myName); ts.setTimeFormat(TimeSelector.TWENTY_FOUR_HOUR); ts.setMinuteInterval(1); ts.setSecondInterval(1); ts.setShowSeconds(true); timeSelect = ts.toString();
Modifier and Type | Field and Description |
---|---|
static String |
AMPM_SUFFIX
Suffix for am/pm parameter.
|
static String |
DEFAULT_PREFIX
Prefix for time names.
|
static String |
HOUR_SUFFIX
Suffix for hour parameter.
|
static String |
MINUTE_SUFFIX
Suffix for minute parameter.
|
static String |
SECOND_SUFFIX
Suffix for second parameter.
|
static int |
TWELVE_HOUR
Constant for 12hr format
|
static int |
TWENTY_FOUR_HOUR
Constant for 24hr format
|
Constructor and Description |
---|
TimeSelector()
Constructor defaults to current date/time and uses the default
prefix: TimeSelector.DEFAULT
|
TimeSelector(String selName)
Constructor defaults to current date/time.
|
TimeSelector(String selName,
Calendar useDate)
Constructor, uses the date/time set in the calendar
passed in (with the date/time set correctly).
|
Modifier and Type | Method and Description |
---|---|
org.apache.ecs.ElementContainer |
ecsOutput()
Return an ECS container with the select objects inside.
|
static org.apache.ecs.html.Select |
getAMPMSelector(String name)
Return an am/pm selector.
|
static org.apache.ecs.html.Select |
getAMPMSelector(String name,
Calendar now)
Return an am/pm selector.
|
static org.apache.ecs.html.Select |
getHourSelector(String name)
Return an 12 hour selector.
|
static org.apache.ecs.html.Select |
getHourSelector(String name,
Calendar now)
Return an 12 hour selector.
|
static org.apache.ecs.html.Select |
getHourSelector(String name,
Calendar now,
int format)
Return an hour selector (either 12hr or 24hr depending on
format . |
static org.apache.ecs.html.Select |
getMinuteSelector(String name)
Return a minute selector.
|
static org.apache.ecs.html.Select |
getMinuteSelector(String name,
Calendar now)
Return a minute selector.
|
static org.apache.ecs.html.Select |
getMinuteSelector(String name,
Calendar now,
int interval)
Return a minute selector.
|
static org.apache.ecs.html.Select |
getSecondSelector(String name)
Return a second selector.
|
static org.apache.ecs.html.Select |
getSecondSelector(String name,
Calendar now)
Return a second selector.
|
static org.apache.ecs.html.Select |
getSecondSelector(String name,
Calendar now,
int interval)
Return a second selector.
|
String |
getSelName()
Get the selector name prefix.
|
String |
output()
Used to build the popupmenu in HTML.
|
TimeSelector |
setMinuteInterval(int minutes)
Set the interval between options in the minute select box.
|
TimeSelector |
setOnChange(String onChange)
Adds the onChange to all of
<SELECT> tags. |
TimeSelector |
setSecondInterval(int seconds)
Set the interval between options in the second select box.
|
TimeSelector |
setSeconds(int seconds)
Select the second to be selected if the showSeconds(false) behavior
is used.
|
void |
setSelName(String selName)
Set the selector name prefix.
|
TimeSelector |
setShowSeconds(boolean show)
Whether or not to show the seconds as a popup menu.
|
TimeSelector |
setTimeFormat(int format)
Set the time format to 12 or 24 hour.
|
String |
toString()
Used to build the popupmenu in HTML.
|
public static final String DEFAULT_PREFIX
public static final String HOUR_SUFFIX
public static final String MINUTE_SUFFIX
public static final String SECOND_SUFFIX
public static final String AMPM_SUFFIX
public static final int TWELVE_HOUR
public static final int TWENTY_FOUR_HOUR
public TimeSelector()
TimeSelector.DEFAULT
public TimeSelector(String selName, Calendar useDate)
selName
- A String with the selector name.useDate
- A Calendar with a date/time.public TimeSelector(String selName)
selName
- A String with the selector name.public TimeSelector setOnChange(String onChange)
<SELECT>
tags.
This is limited to one function for all three popups and is only
used when the output() methods are used. Individual getHour,
getMinute, getSecond, getAMPM static methods will not use this
setting.onChange
- A String to use for onChange attribute. If null,
then nothing will be set.public TimeSelector setSeconds(int seconds)
seconds
- The second.public TimeSelector setMinuteInterval(int minutes)
minutes
- Interval in minutes.public TimeSelector setSecondInterval(int seconds)
seconds
- Interval in seconds.public TimeSelector setTimeFormat(int format)
format
- Time format.public TimeSelector setShowSeconds(boolean show)
show
- True if the second should be shown.public void setSelName(String selName)
selName
- A String with the select name prefix.public String getSelName()
public static org.apache.ecs.html.Select getSecondSelector(String name)
name
- The name to use for the selected second.public static org.apache.ecs.html.Select getSecondSelector(String name, Calendar now)
name
- The name to use for the selected second.now
- Calendar to start with.public static org.apache.ecs.html.Select getSecondSelector(String name, Calendar now, int interval)
name
- The name to use for the selected second.now
- Calendar to start with.interval
- Interval between options.public static org.apache.ecs.html.Select getMinuteSelector(String name)
name
- The name to use for the selected minute.public static org.apache.ecs.html.Select getMinuteSelector(String name, Calendar now)
name
- The name to use for the selected minute.now
- Calendar to start with.public static org.apache.ecs.html.Select getMinuteSelector(String name, Calendar now, int interval)
name
- The name to use for the selected minute.now
- Calendar to start with.interval
- Interval between options.public static org.apache.ecs.html.Select getHourSelector(String name)
name
- The name to use for the selected hour.public static org.apache.ecs.html.Select getHourSelector(String name, Calendar now)
name
- The name to use for the selected hour.now
- Calendar to start with.public static org.apache.ecs.html.Select getHourSelector(String name, Calendar now, int format)
format
.name
- The name to use for the selected hour.now
- Calendar to start with.format
- Time format.public static org.apache.ecs.html.Select getAMPMSelector(String name)
name
- The name to use for the selected am/pm.public static org.apache.ecs.html.Select getAMPMSelector(String name, Calendar now)
name
- The name to use for the selected am/pm.now
- Calendar to start with.public String output()
public String toString()
public org.apache.ecs.ElementContainer ecsOutput()
Copyright © 2000–2018 The Apache Software Foundation. All rights reserved.