Value range of the Date data type
FirstSpirit provides the data type Date for the processing/editing of values which represent a date and/or a time. This data type enables interpretation of different date formats as Year, Month, Day, Hour, Minute and Second. The data type provides access to a range of methods which fall back on the calendar and relevant regional schema settings of the operating system (e.g. data formats) and therefore enable formatting in different, for example country-specific date formats and parsing.
The data type Date can also be looked up in the Sun API documentation:
java.util.Date
Definition
In FirstSpirit, when a date is defined a Date object of the class java.util.Date is generated. This data type is usually generated by means of the CMS_INPUT_DATE input component. Irrespective of this the .now method of the system object #global can be used to generate a new date object:
CMS_SET(myDate, #global.now)$
In this case the expression #global.now returns the current date.
Definition using the standard input components
Within the form area of a page or section template, input components are defined which can be subsequently used by the editors to insert the actual editorial contents into the page. The standard input components supported by FirstSpirit return different data types.
The following standard input components return an object of data type Date :
Then, with the help of a $CMS_VALUE(...)$ instruction, methods can then be applied to this object:
$CMS_VALUE(IDENTIFIER.METHOD)$
IDENTIFIER is the identifier defined in the resultname parameter of the input component.
Methods on date objects
The table below lists all methods which can be invoked on objects of data type Date.
after(Date)
Method name |
Return type |
Available since |
after(Date) |
boolean |
|
Overview
before(Date)
Method name |
Return type |
Available since |
before(Date) |
boolean |
|
Overview
compareTo(Date)
Method name |
Return type |
Available since |
compareTo(Date) |
int |
|
Overview
compareTo(Object)
Method name |
Return type |
Available since |
compareTo(Object) |
int |
|
Overview
equals(Object)
Method name |
Return type |
Available since |
equals(Object) |
boolean |
|
Overview
from(Instant)
Method name |
Return type |
Available since |
from(Instant) |
Date |
|
Overview
getClass
The .getClass() (in Bean syntax: .class) method returns the class of the invoking object (cf. java.lang.Class).
Invocation:
$CMS_VALUE(myString.class)$
$CMS_VALUE(myString.getClass())$
Output:
java.lang.String
Method name |
Return type |
Available since |
getClass |
Class |
|
Overview
getTime
Method name |
Return type |
Available since |
getTime |
long |
|
Overview
isCase(Object)
Method name |
Return type |
Available since |
isCase(Object) |
boolean |
|
Overview
isNull
The .isNull() (in Bean syntax: .isNull) method checks whether an expression or object is null , e.g. storeElement.isNull(). In the case of objects with complex values or objects, the object decides when it is null. The data type DomElement for example always contains an empty document, thus it is never null. For this reason, checking an empty DOM editor input component by using the method .isNull() returns the value false, whereas checking the component with .isEmpty() would return the value true.
The method .isNull() returns a Boolean value as the check result. true is the check result if the expression or object is null and false if not.
Method name |
Return type |
Available since |
isNull |
boolean |
|
Overview
print
Method name |
Return type |
Available since |
print |
void |
|
Overview
set(String, Object)
Method name |
Return type |
Available since |
set(String, Object) |
Object |
|
Overview
setTime(long)
Method name |
Return type |
Available since |
setTime(long) |
void |
|
Overview
toInstant
Method name |
Return type |
Available since |
toInstant |
Instant |
|
Overview
toJSON
Convert to a JSON-compatible string representation including necessary quotes and escaping for immediate use. Handles Maps, Collections, Arrays, Numbers, Strings, Boolean, Date, and JsonElement. A date instance will be converted to an ISO-8601 formatted date string. Any object other than above will be converted using its 'toString()' value.
Method name |
Return type |
Available since |
toJSON |
String |
5.2.11 |
Overview
toString
Method name |
Return type |
Available since |
toString |
String |
|
Overview
type
Method name |
Return type |
Available since |
type |
String |
|
Overview
Print version | Page start