Date Literals
The date literal is always of type
Date
. The following are the different syntax formats you
can use to enter a date.
DateLiteral:
DateDeclarator [n o w ]
DateDeclarator [DateDesignator TimeDesignatoropt]
DateDeclarator [ DateDesignator TimeDesignatoropt ]
DateDeclarator: one of
d D
DateDesignator:
FullDatePattern:
Defined by the pattern "EEEE, MMMM d, yyyy"
LongDatePattern:
Defined by the pattern "MMMM d, yyyy"
MediumDatePattern:
Defined by the pattern "MMM d, yyyy"
ShortDatePattern:
Defined by the pattern "M/d/yy"
TimeDesignator:
FullTimePattern:
Defined by the pattern "h:mm:ss a z"
LongTimePattern:
Defined by the pattern "h:mm:ss a z"
MediumTimePattern:
Defined by the pattern "h:mm:ss a"
ShortTimePattern:
Defined by the pattern "h:mm a"
Example Date Literals:
D[12/13/52]
D[Dec 13, 1952]
D[Thu, July 4, 2002]
D[July 5, 2002]
D[July 7, 2002]
D[7/6/02]
D[Thu, July 4, 2002 5:59 PM]
D[July 5, 2002 5:59 PM]
D[July 7, 2002 5:59 PM]
D[7/6/02 5:59 PM]
D[Thu, July 4, 2002 12:23:59 AM]
D[July 5, 2002 12:23:59 AM]
D[July 7, 2002 12:23:59 AM]
D[7/6/02 12:23:59 AM]
D[Thu, July 4, 2002 12:23:59 AM CST]
D[July 5, 2002 12:23:59 AM CST]
D[July 7, 2002 12:23:59 AM CST]
D[7/6/02 12:23:59 AM CST]
D[now]
Details for the date and time patterns are available in the documentation of the java.text.DateFormat class. If the string now is used, then the literal corresponds to the current date in the server's default timezone at the time the literal is evaluated for the first time.
Each date literal is a reference to an instance of class java.util.Date.