com.ibm.xsp.convert
Class DateTimeConverter

java.lang.Object
  extended by javax.faces.convert.DateTimeConverter
      extended by com.ibm.xsp.convert.DateTimeConverter
All Implemented Interfaces:
ClientSideConverter, javax.faces.component.StateHolder, javax.faces.convert.Converter

public class DateTimeConverter
extends javax.faces.convert.DateTimeConverter
implements ClientSideConverter

The xp:convertDateTime tag extends the standard date time converter to use the ICU library. Not intended to be subclassed.

See Also:
ICU - International Components for Unicode

Field Summary
static java.lang.String CONVERTER_ID
          The converter id for this converter.
static java.lang.String TYPE_BOTH
          The "both date and time" value of the type property.
static java.lang.String TYPE_DATE
          The date-only value of the type property.
static java.lang.String TYPE_TIME
          The time-only value of the type property.
 
Constructor Summary
DateTimeConverter()
           
 
Method Summary
protected  java.lang.Object createDateOnlyFormat(java.util.Locale locale, int dateStyleInt)
          Return date for locale given the dateStyleInt
protected  java.lang.Object createDateTimeFormat(java.util.Locale locale, int dateStyleInt, int timeStyleInt)
          Return date/time for locale give the dateStyleInt and timeStyleInt
protected  java.lang.String createFormatKey(boolean date, boolean time)
          Constructs an apostrophe delimited string given DateTimeConverter.getPattern(), date, time, locale and timezone
protected  java.lang.Object createPatternFormat(java.util.Locale locale, java.lang.String pattern)
          Return SimpleDateFormat for locale with pattern
protected  java.lang.Object createTimeOnlyFormat(java.util.Locale locale, int timeStyleInt)
          Return time for locale given the timeStyleInt
protected  java.lang.Object findDateFormat(javax.faces.context.FacesContext context, boolean date, boolean time)
          Return date and / or time format for given context
protected  java.lang.String format(java.lang.Object dateFormat, java.util.Date dateValue)
          Return dateValue as a String in dateFormat
 java.lang.String generateClientSideConverter(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Return string depending on value of DateTimeConverter.getType() Otherwise, null if no type is set
 java.lang.Object getAsObject(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String value)
          Return value as an object
 java.lang.String getAsString(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.Object value)
          Return value as a string.
 java.lang.String getBothDatePattern(javax.faces.context.FacesContext context)
          Return the pattern for formatting and parsing a date string.
 java.lang.String getBothTimePattern(javax.faces.context.FacesContext context)
          Return the pattern for formatting and parsing a time string.
protected  java.lang.Object getCachedFormat(java.lang.String key)
          Look for the cached date/time format
 java.lang.String getDatePattern(javax.faces.context.FacesContext context)
          Return the pattern for formatting and parsing a date string.
protected  java.util.Locale getDefaultLocale()
          Return the Locale of the root component for the current FacesContext instance.
protected  java.util.TimeZone getDefaultTimeZone()
          Return the user time zone if possible.
static SystemCache getICUDateFormats()
          Not intended to be used by 3rd parties, only by the XPages runtime.
 com.ibm.icu.util.TimeZone getICUTimeZone()
          Return the TimeZone as an ICU TimeZone
 java.util.Locale getLocale()
          Return the Locale set using setLocale(Locale).
 java.lang.String getTimePattern(javax.faces.context.FacesContext context)
          Return the pattern for formatting and parsing a time string.
 java.util.TimeZone getTimeZone()
          Return the TimeZone set using setTimeZone(TimeZone).
protected  void initFormat(java.lang.Object dateFormatObj)
          Initialize dateFormatObj with ICU time zone
 boolean isDatePatternSet()
          Return true if a pattern has been set using setPattern(String).
 boolean isIgnoreUserTimeZone()
          Return true if this has been set using setIgnoreUserTimeZone(boolean)
protected  java.util.Date parse(java.lang.Object dateFormat, java.lang.String value)
          Return value as a Date object in dateFormat
protected  void putCachedFormat(java.lang.String key, java.lang.Object format)
          Add the cached date format
 void restoreState(javax.faces.context.FacesContext context, java.lang.Object state)
           
 java.lang.Object saveState(javax.faces.context.FacesContext context)
           
 void setIgnoreUserTimeZone(boolean ignoreUserTimeZone)
          Specify whether the user time zone should be ignored.
 void setLocale(java.util.Locale locale)
          Specifies a locale to use when formatting and parsing styles for dates and times.
 void setPattern(java.lang.String pattern)
          Specifies a pattern for formatting and parsing the date and time string.
 void setTimeZone(java.util.TimeZone timeZone)
          Specifies a time zone to use when formatting and parsing styles for dates and times.
protected  java.lang.String toPattern(java.lang.Object dateFormat)
          Return date/time as string in dateFormat
 
Methods inherited from class javax.faces.convert.DateTimeConverter
getDateStyle, getPattern, getTimeStyle, getType, isTransient, setDateStyle, setTimeStyle, setTransient, setType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONVERTER_ID

public static final java.lang.String CONVERTER_ID
The converter id for this converter.

See Also:
Constant Field Values

TYPE_DATE

public static final java.lang.String TYPE_DATE
The date-only value of the type property. One of the possible values of DateTimeConverter.getType(), this indicates that only the date is used, not the time portion of the Date object

See Also:
Constant Field Values

TYPE_TIME

public static final java.lang.String TYPE_TIME
The time-only value of the type property. One of the possible values of DateTimeConverter.getType(), this indicates that only the time is used, not the date portion of the Date object

See Also:
Constant Field Values

TYPE_BOTH

public static final java.lang.String TYPE_BOTH
The "both date and time" value of the type property. One of the possible values of DateTimeConverter.getType(), this indicates that both the date and the time are used from the Date object.

See Also:
Constant Field Values
Constructor Detail

DateTimeConverter

public DateTimeConverter()
Method Detail

getICUDateFormats

public static SystemCache getICUDateFormats()
Not intended to be used by 3rd parties, only by the XPages runtime.


getLocale

public java.util.Locale getLocale()
Return the Locale set using setLocale(Locale). Otherwise, the default Locale is returned.

Overrides:
getLocale in class javax.faces.convert.DateTimeConverter

getDefaultLocale

protected java.util.Locale getDefaultLocale()
Return the Locale of the root component for the current FacesContext instance.


setLocale

public void setLocale(java.util.Locale locale)
Specifies a locale to use when formatting and parsing styles for dates and times.

Overrides:
setLocale in class javax.faces.convert.DateTimeConverter

setPattern

public void setPattern(java.lang.String pattern)
Specifies a pattern for formatting and parsing the date and time string.

Overrides:
setPattern in class javax.faces.convert.DateTimeConverter

getTimeZone

public java.util.TimeZone getTimeZone()
Return the TimeZone set using setTimeZone(TimeZone). Otherwise, the default TimeZone is returned.

Overrides:
getTimeZone in class javax.faces.convert.DateTimeConverter

setTimeZone

public void setTimeZone(java.util.TimeZone timeZone)
Specifies a time zone to use when formatting and parsing styles for dates and times.

Overrides:
setTimeZone in class javax.faces.convert.DateTimeConverter

getICUTimeZone

public com.ibm.icu.util.TimeZone getICUTimeZone()
Return the TimeZone as an ICU TimeZone


getDefaultTimeZone

protected java.util.TimeZone getDefaultTimeZone()
Return the user time zone if possible. Otherwise, the server time zone is returned.


isDatePatternSet

public boolean isDatePatternSet()
Return true if a pattern has been set using setPattern(String).


getDatePattern

public java.lang.String getDatePattern(javax.faces.context.FacesContext context)
Return the pattern for formatting and parsing a date string.


getTimePattern

public java.lang.String getTimePattern(javax.faces.context.FacesContext context)
Return the pattern for formatting and parsing a time string.


getBothDatePattern

public java.lang.String getBothDatePattern(javax.faces.context.FacesContext context)
Return the pattern for formatting and parsing a date string.


getBothTimePattern

public java.lang.String getBothTimePattern(javax.faces.context.FacesContext context)
Return the pattern for formatting and parsing a time string.


isIgnoreUserTimeZone

public boolean isIgnoreUserTimeZone()
Return true if this has been set using setIgnoreUserTimeZone(boolean)


setIgnoreUserTimeZone

public void setIgnoreUserTimeZone(boolean ignoreUserTimeZone)
Specify whether the user time zone should be ignored.


getAsString

public java.lang.String getAsString(javax.faces.context.FacesContext context,
                                    javax.faces.component.UIComponent component,
                                    java.lang.Object value)
Return value as a string.

Specified by:
getAsString in interface javax.faces.convert.Converter
Overrides:
getAsString in class javax.faces.convert.DateTimeConverter

getAsObject

public java.lang.Object getAsObject(javax.faces.context.FacesContext context,
                                    javax.faces.component.UIComponent component,
                                    java.lang.String value)
Return value as an object

Specified by:
getAsObject in interface javax.faces.convert.Converter
Overrides:
getAsObject in class javax.faces.convert.DateTimeConverter

createFormatKey

protected java.lang.String createFormatKey(boolean date,
                                           boolean time)
Constructs an apostrophe delimited string given DateTimeConverter.getPattern(), date, time, locale and timezone


getCachedFormat

protected java.lang.Object getCachedFormat(java.lang.String key)
Look for the cached date/time format


putCachedFormat

protected void putCachedFormat(java.lang.String key,
                               java.lang.Object format)
Add the cached date format


findDateFormat

protected java.lang.Object findDateFormat(javax.faces.context.FacesContext context,
                                          boolean date,
                                          boolean time)
Return date and / or time format for given context


restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         java.lang.Object state)
Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class javax.faces.convert.DateTimeConverter

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext context)
Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class javax.faces.convert.DateTimeConverter

toPattern

protected java.lang.String toPattern(java.lang.Object dateFormat)
Return date/time as string in dateFormat


createDateOnlyFormat

protected java.lang.Object createDateOnlyFormat(java.util.Locale locale,
                                                int dateStyleInt)
Return date for locale given the dateStyleInt


createTimeOnlyFormat

protected java.lang.Object createTimeOnlyFormat(java.util.Locale locale,
                                                int timeStyleInt)
Return time for locale given the timeStyleInt


createDateTimeFormat

protected java.lang.Object createDateTimeFormat(java.util.Locale locale,
                                                int dateStyleInt,
                                                int timeStyleInt)
Return date/time for locale give the dateStyleInt and timeStyleInt


createPatternFormat

protected java.lang.Object createPatternFormat(java.util.Locale locale,
                                               java.lang.String pattern)
Return SimpleDateFormat for locale with pattern


initFormat

protected void initFormat(java.lang.Object dateFormatObj)
Initialize dateFormatObj with ICU time zone


parse

protected java.util.Date parse(java.lang.Object dateFormat,
                               java.lang.String value)
                        throws java.text.ParseException
Return value as a Date object in dateFormat

Throws:
java.text.ParseException

format

protected java.lang.String format(java.lang.Object dateFormat,
                                  java.util.Date dateValue)
Return dateValue as a String in dateFormat


generateClientSideConverter

public java.lang.String generateClientSideConverter(javax.faces.context.FacesContext context,
                                                    javax.faces.component.UIComponent component)
                                             throws java.io.IOException
Return string depending on value of DateTimeConverter.getType() Otherwise, null if no type is set

Specified by:
generateClientSideConverter in interface ClientSideConverter
Throws:
java.io.IOException