formatDate"

From Documentation
 
(3 intermediate revisions by 2 users not shown)
Line 10: Line 10:
  
 
Formats a Date into a date/time string with the given pattern.
 
Formats a Date into a date/time string with the given pattern.
 
+
For example,
There is another extended built in function,  
+
<source lang="xml">
 
+
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<source lang="java">
+
<zk>
String formatDate(Date date, String pattern, Locale locale, TimeZone timezone, String dateStyle, String timeStyle);
+
<zscript>
 +
java.util.Date date = new java.util.Date();
 +
</zscript>
 +
<label value="${c:formatDate(date, 'MM/dd/yyyy')}" />
 +
</zk>
 
</source>
 
</source>
  
:i.e., <javadoc method="formatDate(Date, String, Locale, TimeZone, String, String)">org.zkoss.xel.fn.CommonFns</javadoc>
+
There is another extended built-in function: <javadoc method="formatDate(Date, String, Locale, TimeZone, String, String)">org.zkoss.xel.fn.CommonFns</javadoc>, not declared in taglib.
  
Formats a Date into a date/time string with the given pattern, locale, timezone, date style and time style.
+
Formats a Date into a date/time string with the given pattern, locale, timezone, date style, and time style.
  
You can define a method to use this function by [http://books.zkoss.org/wiki/ZUML_Reference/ZUML/Processing_Instructions/xel-method xel-method]
+
You can call it by [[ZUML%20Reference/EL%20Expressions/Static%20Fields%20and%20Methods| EL]] or declaring a [[ZUML_Reference/ZUML/Processing_Instructions/xel-method| xel-method]].
  
 
<blockquote>
 
<blockquote>
 
----
 
----
Note: If the date style / time style is applied, the pattern will be ignored.
+
Note: If the date style/time style is applied, the pattern will be ignored.
 
</blockquote>
 
</blockquote>
  

Latest revision as of 07:57, 27 May 2021

The default method:

String formatDate(Date date, String pattern);
i.e., CommonFns.formatDate(Date, String)

Formats a Date into a date/time string with the given pattern. For example,

<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<zk>
	<zscript>
		java.util.Date date = new java.util.Date();
	</zscript>
	<label value="${c:formatDate(date, 'MM/dd/yyyy')}" />
</zk>

There is another extended built-in function: CommonFns.formatDate(Date, String, Locale, TimeZone, String, String), not declared in taglib.

Formats a Date into a date/time string with the given pattern, locale, timezone, date style, and time style.

You can call it by EL or declaring a xel-method.


Note: If the date style/time style is applied, the pattern will be ignored.

Parameters: In both default and extended function:

  • date - the Date to format
  • pattern - the pattern to apply

In extended function only:

  • locale - the locale to apply
  • timezone - the timezone to apply
  • dateStyle - the date style to apply
  • timeStyle - the time style to apply

Version History

Last Update : 2021/05/27


Version Date Content
6.0.0    



Last Update : 2021/05/27

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.