1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
## Licensed to the Apache Software Foundation (ASF) under one
## or more contributor license agreements. See the NOTICE file
## distributed with this work for additional information
## regarding copyright ownership. The ASF licenses this file
## to you under the Apache License, Version 2.0 (the
## "License"); you may not use this file except in compliance
## with the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing,
## software distributed under the License is distributed on an
## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
## KIND, either express or implied. See the License for the
## specific language governing permissions and limitations
## under the License.
#title( 'DateTool' )
<p>
#set( $demo = $text.demo )
$demo.thisPage.insert("#doclink( 'DateTool' true )") and its subclass, the
#doclink( 'ComparisonDateTool' true ). As the DateTool
is quite full-featured and provides many similar functions with varying and
strongly-typed options, not all functions are demonstrated below. See the javadoc
for a full listing of available functions.
</p>
#demoTableStart()
#set( $quote = '' )
#set( $desc = 'Converts the specified object to a date and formats it according to the pattern or style returned by $date.format.' )
#demo1( 'date' 'format' 4 $desc)
#set( $desc = 'Converts the specified object to a date and formats it according to the specified date format.' )
#demo2( 'date' 'format' 4 $desc )
#set( $desc = 'Returns the value of $date.date as a string formatted according to the specified date format.' )
#demo1( 'date' 'get' 4 $desc )
#set( $desc = 'Returns a formatted string representing the date and/or time given by $date.date in the specified date and time styles.' )
#demo2( 'date' 'get' 4 $desc )
#set( $desc = 'Returns the day (of the month) value of the date returned by $date.calendar' )
#demo( 'date' 'day' $desc )
#set( $desc = 'Returns the day (of the month) value for the specified date.' )
#demo1( 'date' 'getDay' 4 $desc )
#set( $desc = 'Returns the month value of the date returned by $date.calendar.' )
#demo( 'date' 'month' $desc )
#set( $desc = 'Returns the month value of the specified date.' )
#demo1( 'date' 'getMonth' 4 $desc )
#set( $desc = 'Returns the year value of the date returned by $date.calendar.' )
#demo( 'date' 'year' $desc )
#set( $desc = 'Returns the year value of the specified date.' )
#demo1( 'date' 'getYear' 4 $desc )
#set( $desc = 'Return the specified value of the date returned by $date.calendar or null if the field is invalid.' )
#demo1( 'date' 'getValue' 4 $desc )
#set( $desc = 'Returns the specified value of the specified date, or null if the field or date is invalid.' )
#demo2( 'date' 'getValue' 4 $desc )
#set( $desc = 'Returns a Date derived from the result of $date.calendar' )
#demo( 'date' 'date' $desc )
#set( $desc = 'Return the pattern or style to be used for formatting dates when none is specified.' )
#demo( 'date' 'format' $desc )
#set( $desc = 'This returns the default Locale configured for this instance.' )
#demo( 'date' 'locale' $desc )
#set( $desc = 'This returns the id of the default TimeZone configured for this instance.' )
#demo( 'date' 'timeZone.ID' $desc )
#set( $desc = 'Gets the Date at the time this page was rendered for the system running this application.' )
#demo( 'date' 'systemDate' $desc )
#set( $desc = 'Converts an object to an instance of Calendar using the locale returned by $date.locale if necessary.' )
#demo1( 'date' 'toCalendar' 4 $desc )
#set( $desc = 'Converts an object to an instance of Date using the format returned by $date.format,the Locale returned by $date.locale, and the TimeZone returned by $date.timeZone if the object is not already an instance of Date, Calendar, or Long.' )
#demo1( 'date' 'toDate' 4 $desc )
#set( $desc = 'Converts an object to an instance of Date using the specified format,the Locale returned by $date.locale, and the TimeZone returned by $date.timeZone if the object is not already an instance of Date, Calendar, or Long.' )
#demo2( 'date' 'toDate' 4 $desc )
#demoCustom( 'date' )
</table>
<br>
<p>
Here are a few demos of the functions provided by the
#doclink( 'ComparisonDateTool' true ) class that are not in the standard
DateTool.
</p>
#demoTableStart()
#set( $desc = "This returns a #doclink( 'ComparisonDateTool.Comparison' true ) between the result of ${esc.d}date.calendar and the specified date. The default rendering of that Comparison will be the largest unit difference between the dates followed by a description of their relative position." )
#demo1( 'date' 'whenIs' 6 $desc )
#set( $desc = "This returns a #doclink( 'ComparisonDateTool.Comparison' true ) between the second specified date and the first specified date. The default rendering of that Comparison will be the largest unit difference between the dates followed by a description of their relative position." )
#demo2( 'date' 'whenIs' 6 $desc )
#set( $desc = "This returns a #doclink( 'ComparisonDateTool.Comparison' true ) between the second specified date and the first specified date. The default rendering of that Comparison will be the largest unit difference between the dates." )
#demo2( 'date' 'difference' 6 $desc )
#demoCustom( "date.whenIs('2005-07-04').depth(3)" )
</table>
<div align="center">
<a name="fullDemo"><h3>$demo.mainExampleHeader</h3></a>
<form method="post" action="$link.self.anchor('fullDemo')">
<textarea name="demo" rows="16" cols="65">##
#if( $params.demo )##
$params.demo##
#else##
${esc.h}${esc.h} Examples of formatting the "current" date:
${esc.d}date
${esc.d}date.long
${esc.d}date.medium_time
${esc.d}date.full_date
${esc.d}date.yyyy
${esc.d}date.get('default','short')
${esc.d}date.get('yyyy-M-d H:m:s')
${esc.h}${esc.h} Examples of comparing dates:
${esc.d}date.whenIs('2005-07-04')
${esc.d}date.whenIs('2005-07-04').full
${esc.d}date.whenIs('2005-02-15').days
${esc.d}date.whenIs(${esc.d}date)
${esc.d}date.whenIs('2005-07-04', '2005-07-04')
${esc.d}date.difference('2005-07-04', '2005-07-04')
${esc.d}date.difference('2005-07-04', '2007-02-15').abbr##
#end##
</textarea>
<br>
<input type="submit" value="$demo.try">
#if( $params.layout )
<input type="hidden" name="layout" value="$params.layout">
#end
</form>
#if( $params.demo )
$demo.mainResultsIntro:
<pre>
$render.eval($params.demo)
</pre>
#end
</div>
|