Date and Time Formatting"
m |
|||
Line 11: | Line 11: | ||
# It checks if an attribute called <tt>org.zkoss.web.preferred.dateFormatInfo</tt> defined in the servlet context (i.e., <javadoc type="interface">org.zkoss.zk.ui.Application</javadoc>). If so, it will be used by assuming the value is an instance or a class of <javadoc type="interface">org.zkoss.text.DateFormatInfo</javadoc>. | # It checks if an attribute called <tt>org.zkoss.web.preferred.dateFormatInfo</tt> defined in the servlet context (i.e., <javadoc type="interface">org.zkoss.zk.ui.Application</javadoc>). If so, it will be used by assuming the value is an instance or a class of <javadoc type="interface">org.zkoss.text.DateFormatInfo</javadoc>. | ||
# It checks if a property called <tt>org.zkoss.web.preferred.dateFormatInfo</tt> defined in the library property (i.e., <javadoc >org.zkoss.lang.Library</javadoc>). If so, it will be used by assuming the value is a class of <javadoc type="interface">org.zkoss.text.DateFormatInfo</javadoc>. | # It checks if a property called <tt>org.zkoss.web.preferred.dateFormatInfo</tt> defined in the library property (i.e., <javadoc >org.zkoss.lang.Library</javadoc>). If so, it will be used by assuming the value is a class of <javadoc type="interface">org.zkoss.text.DateFormatInfo</javadoc>. | ||
+ | # If none of them is found, it uses the JVM's default based on [[ZK Developer's Reference/Internationalization/Locale|the current locale]] | ||
− | + | In other words, to configure ZK to use the format other than the JVM's default, you have to: | |
+ | |||
+ | # Implements <javadoc type="interface">org.zkoss.text.DateFormatInfo</javadoc> to provide the format you want | ||
+ | # Specify the class or an instance of it in the session's attribute or application's attribute depending on the requirement of your application. | ||
+ | |||
+ | Also notice that you could specify <tt>short</tt>, <tt>long</tt> and other ''standard'' styling in the format property of datebox and timebox, such that the corresponding format of the styling will be used instead of the default, <tt>meidum</tt>. For more information, please refer to [[#Per-component Format|the Per-component Format section]]. | ||
== Application-level Format == | == Application-level Format == | ||
== Per-user Format == | == Per-user Format == | ||
== Per-component Format == | == Per-component Format == | ||
+ | |||
=Version History= | =Version History= | ||
{{LastUpdated}} | {{LastUpdated}} |
Revision as of 06:40, 25 April 2011
Overview
By default, the format of date and time, especially the format of Datebox and Timebox, is determined by the JVM's default and the current locale.
In this section, we will discuss how to configure ZK to use the format other than the JVM. For example, you could configure ZK to use the preferred format based on user's preferences.
The Decision Sequence of Format
The format of date and time is decided in the following sequence.
- It checks if an attribute called org.zkoss.web.preferred.dateFormatInfo defined in the HTTP session (i.e., Session). If so, it will be used by assuming the value is an instance or a class of DateFormatInfo.
- It checks if an attribute called org.zkoss.web.preferred.dateFormatInfo defined in the servlet context (i.e., Application). If so, it will be used by assuming the value is an instance or a class of DateFormatInfo.
- It checks if a property called org.zkoss.web.preferred.dateFormatInfo defined in the library property (i.e., Library). If so, it will be used by assuming the value is a class of DateFormatInfo.
- If none of them is found, it uses the JVM's default based on the current locale
In other words, to configure ZK to use the format other than the JVM's default, you have to:
- Implements DateFormatInfo to provide the format you want
- Specify the class or an instance of it in the session's attribute or application's attribute depending on the requirement of your application.
Also notice that you could specify short, long and other standard styling in the format property of datebox and timebox, such that the corresponding format of the styling will be used instead of the default, meidum. For more information, please refer to the Per-component Format section.
Application-level Format
Per-user Format
Per-component Format
Version History
Version | Date | Content |
---|---|---|
5.0.7 | April 2011 | The per-session format of datebox/timebox was introduced. Prior to 5.0.7, the format depends only on locale. |