com.filenet.wcm.apps.server.presentation.util
Class DateTimeControl

java.lang.Object
  extended bycom.filenet.wcm.apps.server.presentation.util.DateTimeControl

public class DateTimeControl
extends java.lang.Object

DateTimeControl is a utility class that provides a DHTML calendar control presentation for showing and updating datetime values on an HTML form. A UI module that uses this control presentation must make the includeHeaders call in its initialize() or onStartPage() call. For forward compatibility, this interface needs to be used exclusively to leverage the DHTML calendar control. The underlying calendar control used by this interface may change in the future. All of methods provided take locale and style as parameters in order to get the JDK OptimizedDateFormat format object appropriate for that locale and file. The normalized pattern that is accessible through this class via getNormalizedPattern is the format pattern used by the DHTML calendar control, and represents the formatted date that is sent to the server when a form is submitted. The normalized pattern for the specified locale and style may or may not directly match the pattern that would be returned from OptimizedDateFormat.getDateFormat/getDateTimeFormat, so the normalized format/pattern needs to be used when parsing datetime values specified using the DHTML calendar control.


Nested Class Summary
static class DateTimeControl.FormValues
           
static class DateTimeControl.SimplePattern
           
 
Field Summary
static com.filenet.wcm.toolkit.util.WcmString[] FORMAT_LABELS
           
static int[] FORMAT_STYLES
           
 
Method Summary
static java.lang.String[] getDateStyleStrings(java.util.Locale locale)
          Return an array of the normalized format patterns representing DateTime.SHORT, MEDIUM, LONG and FULL.
static java.lang.String getDisplayDate(java.util.Calendar utcDate, java.util.Locale locale, java.util.TimeZone timeZone, int dateStyle, int timeStyle, boolean showTime)
          Get the formatted date based on the specified locale and style parameters.
static java.lang.String getDisplayDate(java.lang.String isoDate, java.util.Locale locale, java.util.TimeZone timeZone, int dateStyle, int timeStyle, boolean showTime)
          Get the formatted date based on the specified locale and style paramters.
static java.lang.String getDisplayDate(java.lang.String isoDate, java.lang.String localeString, java.lang.String timeZoneString, java.lang.String dateStyleString, java.lang.String timeStyleString, boolean showTime)
          Get the formatted date based on the specified locale and style paramters.
static DateTimeControl.FormValues getFormValues(javax.servlet.http.HttpServletRequest request, java.lang.String elementName)
          Gets all of the information for a request element representing the dateTime control.
static DateTimeControl.FormValues getFormValues(java.util.Map parameterMap, java.lang.String elementName)
          Gets all of the information for a request element representing the dateTime control.
static java.lang.String getHTML(DateTimeControlSettings dateTimeControlSettings, java.lang.String elementName, java.lang.String currentW3CValue, java.lang.String inputClass)
           
static java.lang.String getHTML(java.util.Locale locale, java.util.TimeZone timeZone, int dateStyle, int timeStyle, java.lang.String elementName, java.lang.String currentW3CValue, java.lang.String inputClass, boolean showTime)
          Get the HTML representing a calendar control form element.
static java.lang.String getHTML(java.util.Locale locale, java.util.TimeZone timeZone, java.lang.String pattern, java.lang.String elementName, java.lang.String currentW3CValue, java.lang.String inputClass)
           
static java.lang.String getHTML(java.lang.String localeString, java.lang.String timeZoneString, java.lang.String dateStyleString, java.lang.String timeStyleString, java.lang.String elementName, java.lang.String currentW3CValue, java.lang.String inputClass, boolean showTime)
          Get the HTML representing a calendar control form element.
static java.lang.String getISODate(java.util.Locale locale, javax.servlet.http.HttpServletRequest request, java.lang.String elementName, boolean compressed)
          The ISO formatted datetime value.
static java.lang.String getISODate(java.util.Locale locale, java.util.Map parameterMap, java.lang.String elementName, boolean compressed)
          The ISO formatted datetime value.
static java.lang.String getISODate(java.util.Locale locale, java.lang.String rawValue, java.lang.String pattern, java.util.TimeZone timeZone, boolean compressed)
          The ISO formatted datetime value.
static java.util.Calendar getLocalDate(java.util.Locale locale, javax.servlet.http.HttpServletRequest request, java.lang.String elementName)
          Get the date object corresponding to the value entered into a datetime control in the browser.
static java.lang.String[] getTimeStyleStrings(java.util.Locale locale)
          Return an array of the normalized format patterns representing DateTime.SHORT, MEDIUM, LONG and FULL.
static java.util.TimeZone getTimeZone(java.lang.String timeZoneID)
           
static void includeHeaders(com.filenet.wcm.toolkit.server.base.WcmController controller, java.util.Locale locale)
          Make sure that the required calendar javascript files are included in the header.
static void includeHeaders(com.filenet.wcm.toolkit.server.base.WcmController controller, java.util.Locale locale, java.lang.String style)
          Make sure that the required calendar javascript files are included in the header.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORMAT_LABELS

public static final com.filenet.wcm.toolkit.util.WcmString[] FORMAT_LABELS

FORMAT_STYLES

public static final int[] FORMAT_STYLES
Method Detail

includeHeaders

public static void includeHeaders(com.filenet.wcm.toolkit.server.base.WcmController controller,
                                  java.util.Locale locale)
Make sure that the required calendar javascript files are included in the header. Any UI module that will display the date/time control is required to call this method either in their initialize() or onStartPage() method. If the locale is not specified, the local JVM locale will be used.

Parameters:
controller - The current controller.
locale - The locale to use to determine the language for the calendar control to display (optional).

includeHeaders

public static void includeHeaders(com.filenet.wcm.toolkit.server.base.WcmController controller,
                                  java.util.Locale locale,
                                  java.lang.String style)
Make sure that the required calendar javascript files are included in the header. Only do it the first time per each request.

Parameters:
controller -
locale - The locale language to use for display, if supported. If null, the JVM language is used. (optional)
style - The style contstant value representing the style to use. Default is STYLE_SYSTEM. (optional)

getFormValues

public static DateTimeControl.FormValues getFormValues(javax.servlet.http.HttpServletRequest request,
                                                       java.lang.String elementName)
Gets all of the information for a request element representing the dateTime control.

Parameters:
request -
elementName -
Returns:

getFormValues

public static DateTimeControl.FormValues getFormValues(java.util.Map parameterMap,
                                                       java.lang.String elementName)
Gets all of the information for a request element representing the dateTime control.

Parameters:
parameterMap -
elementName -
Returns:

getLocalDate

public static java.util.Calendar getLocalDate(java.util.Locale locale,
                                              javax.servlet.http.HttpServletRequest request,
                                              java.lang.String elementName)
                                       throws java.text.ParseException
Get the date object corresponding to the value entered into a datetime control in the browser. The returned date object is in local time zone.

Parameters:
locale - The locale corresponding to the language being displayed.
request -
elementName -
Returns:
A new Date object representing the date value, if specified. Returns null if no date value is specified for the elementName.
Throws:
java.text.ParseException

getISODate

public static java.lang.String getISODate(java.util.Locale locale,
                                          javax.servlet.http.HttpServletRequest request,
                                          java.lang.String elementName,
                                          boolean compressed)
                                   throws java.text.ParseException
The ISO formatted datetime value. The date value return is shifted from the JVM timezone to UTC.

Parameters:
locale - - The locale corresponding to the language being displayed.
request -
elementName -
compressed - - Whether to return the ISO date in compressed form or hyphenated form.
Returns:
ISO formatted date if date value exists. If blank or undefined returns the result of request.getParameter(elementName).
Throws:
java.text.ParseException

getISODate

public static java.lang.String getISODate(java.util.Locale locale,
                                          java.util.Map parameterMap,
                                          java.lang.String elementName,
                                          boolean compressed)
                                   throws java.text.ParseException
The ISO formatted datetime value. The date value return is shifted from the JVM timezone to UTC.

Parameters:
locale - - The locale corresponding to the language being displayed.
parameterMap -
elementName -
compressed - - Whether to return the ISO date in compressed form or hyphenated form.
Returns:
ISO formatted date if date value exists. If blank or undefined returns the result of request.getParameter(elementName).
Throws:
java.text.ParseException

getISODate

public static java.lang.String getISODate(java.util.Locale locale,
                                          java.lang.String rawValue,
                                          java.lang.String pattern,
                                          java.util.TimeZone timeZone,
                                          boolean compressed)
                                   throws java.text.ParseException
The ISO formatted datetime value. The date value return is shifted from the specified timezone to UTC.

Parameters:
locale - - The locale corresponding to the language being displayed.
rawValue - The current display date value.
pattern - The style, for example, DateTime.SHORT.
timeZone -
compressed - - Whether to return the ISO date in compressed form or hyphenated form.
Returns:
ISO formatted date if date value exists.
Throws:
java.text.ParseException

getDateStyleStrings

public static java.lang.String[] getDateStyleStrings(java.util.Locale locale)
Return an array of the normalized format patterns representing DateTime.SHORT, MEDIUM, LONG and FULL. For use in setting up UI to select the desired date format.

Parameters:
locale -
Returns:
A String[4] array.

getTimeStyleStrings

public static java.lang.String[] getTimeStyleStrings(java.util.Locale locale)
Return an array of the normalized format patterns representing DateTime.SHORT, MEDIUM, LONG and FULL. For use in setting up UI to select the desired date format.

Parameters:
locale -
Returns:
A String[4] array.

getHTML

public static java.lang.String getHTML(java.lang.String localeString,
                                       java.lang.String timeZoneString,
                                       java.lang.String dateStyleString,
                                       java.lang.String timeStyleString,
                                       java.lang.String elementName,
                                       java.lang.String currentW3CValue,
                                       java.lang.String inputClass,
                                       boolean showTime)
Get the HTML representing a calendar control form element. The returned string value can be written out to a page to show the form field for date input. This signature requires only String, int and boolean values, so that it can be called from XSL. A UI module that uses this method must, in its initialize, or onStartPage callback must make a call to include the required JavaScript via the header module.

Parameters:
localeString - The locale being used in the format returned from WcmUi.encodeLocale(locale). Determines the exact date format that is used.
dateStyleString - The style, for example, DateTime.SHORT.
timeStyleString - The style, for example, DateTime.SHORT.
elementName - The element name that will be used for the input textbox containing the formatted date.
currentW3CValue - The current W3C String date value to display. If the value is not a valid W3C format it will not be formatted for display (optional).
inputClass - The CSS style class to use for the input textbox (optional).
showTime - Specify whether or not to show the time in the display pattern.
Returns:

getHTML

public static java.lang.String getHTML(java.util.Locale locale,
                                       java.util.TimeZone timeZone,
                                       java.lang.String pattern,
                                       java.lang.String elementName,
                                       java.lang.String currentW3CValue,
                                       java.lang.String inputClass)

getHTML

public static java.lang.String getHTML(java.util.Locale locale,
                                       java.util.TimeZone timeZone,
                                       int dateStyle,
                                       int timeStyle,
                                       java.lang.String elementName,
                                       java.lang.String currentW3CValue,
                                       java.lang.String inputClass,
                                       boolean showTime)
Get the HTML representing a calendar control form element. The returned string value can be written out to a page to show the form field for date input. A UI module that uses this method must, in its initialize, or onStartPage callback must make a call to include the required JavaScript via the header module.

Parameters:
locale - The locale being used. Determines the exact date format that is used.
dateStyle - The date style, for example, DateTime.SHORT.
timeStyle - The date style, for example, DateTime.SHORT.
elementName - The element name that will be used for the input textbox containing the formatted date.
currentW3CValue - The current W3C String date value to display. If the value is not a valid W3C format it will not be formatted for display (optional).
inputClass - The CSS style class to use for the input textbox (optional).
showTime - Specify whether or not to show the time in the display pattern.
Returns:

getHTML

public static java.lang.String getHTML(DateTimeControlSettings dateTimeControlSettings,
                                       java.lang.String elementName,
                                       java.lang.String currentW3CValue,
                                       java.lang.String inputClass)

getTimeZone

public static java.util.TimeZone getTimeZone(java.lang.String timeZoneID)

getDisplayDate

public static java.lang.String getDisplayDate(java.lang.String isoDate,
                                              java.lang.String localeString,
                                              java.lang.String timeZoneString,
                                              java.lang.String dateStyleString,
                                              java.lang.String timeStyleString,
                                              boolean showTime)
                                       throws com.filenet.wcm.toolkit.util.WcmException
Get the formatted date based on the specified locale and style paramters. The ISO date can be either in long (CE) or short (PE) format. This signature contains all String and boolean parameters so that it can be called from within an XSL template.

Parameters:
isoDate - The ISO date value
localeString - The locale String value obtained using WcmUi.encodeLocale(locale)
dateStyleString - The dateStyle (int) value specified as a String
timeStyleString - The timeStyle (int) value specified as a String
showTime - Specify whether or not to show the time component
Returns:
Throws:
com.filenet.wcm.toolkit.util.WcmException

getDisplayDate

public static java.lang.String getDisplayDate(java.lang.String isoDate,
                                              java.util.Locale locale,
                                              java.util.TimeZone timeZone,
                                              int dateStyle,
                                              int timeStyle,
                                              boolean showTime)
                                       throws com.filenet.wcm.toolkit.util.WcmException
Get the formatted date based on the specified locale and style paramters. The ISO date can be either in long (CE) or short (PE) format. This signature contains all String and boolean parameters so that it can be called from within an XSL template.

Parameters:
isoDate - The ISO date value
locale - The locale object
timeZone - The TimeZone object
dateStyle - The dateStyle (int) value
timeStyle - The timeStyle (int) value
showTime - Specify whether or not to show the time component
Returns:
Throws:
com.filenet.wcm.toolkit.util.WcmException

getDisplayDate

public static java.lang.String getDisplayDate(java.util.Calendar utcDate,
                                              java.util.Locale locale,
                                              java.util.TimeZone timeZone,
                                              int dateStyle,
                                              int timeStyle,
                                              boolean showTime)
Get the formatted date based on the specified locale and style parameters.

Parameters:
utcDate - The date to display
locale - The locale used to determine the date and time style patterns to be used
dateStyle - The date style value (e.g. DateFormat.SHORT, DateFormat.LONG, etc.)
timeStyle - The time style value
showTime - Specify whether or not to show the time component
Returns:


© Copyright IBM Corp. 2002, 2007. All Rights Reserved.